An unofficial, read-only Hacker News reader. Join the beta →

In C++, = default and {} are not the same constructor (opens external site)

129 points by surprisetalk 2 days ago | lemire.me | 198 comments on HN

View full thread · View on Hacker News

Comment thread (1)

  1. I mean, you could just turn warnings on: https://godbolt.org/z/ns6cb9T6q

    But yes, I know that any function with the signature `std::string_view(const std::string&)` or especially `std::string_view(std::string)` is a land mine.

    I asked a local LLM to do a code review on it. (gemma4:12b) It flagged the bug, with all caps "THIS WILL CAUSE UNDEFINED BEHAVIOR", and suggested a fix.