News for hackers. Stuff that matters.
Re:New C++ features in GCC 12 by raydev on Sunday May 01, 2022 @02:04PM (#31227213)
But that would compile and run, and you'd still get garbage if you tried to access str later, correct?

In Swift you are not allowed to declare a variable without assigning some value or nil to it before the current scope ends.

Re:New C++ features in GCC 12 by benchaney on Sunday May 01, 2022 @02:25PM (#31227410)
I don't think that's true. The default constructor for std::string creates an empty string. See: https://www.cplusplus.com/reference/string/string/string/

The semantics of c++ object initialization are such that a constructor will always be called.

Re:New C++ features in GCC 12 by jcelerier on Sunday May 01, 2022 @05:55PM (#31229068)
No, either you get the previous content of the string (if it was under the small-string optimization limit) or a new empty string, but never garbage.
Re:New C++ features in GCC 12 by pjmlp on Monday May 02, 2022 @02:27AM (#31231994)
In C++, you can prevent that with compiler options.