News for hackers. Stuff that matters.
Re:Initialization in C++ is bonkers (2017) by loeg on Thursday May 15, 2025 @08:53PM (#44000813)
I don't really care if it isn't portable. I only have to work with Clang, personally.

> If zero initialization were the default and you had to opt-in with [[uninitialized]] for each declaration it’d be a lot safer.

I support that, too. Just seems harder than getting a flag into Clang or GCC.

Re:Initialization in C++ is bonkers (2017) by ryandrake on Thursday May 15, 2025 @08:55PM (#44000823)
Portability is always for the other guy’s sake, not your own. That’s why so many people don’t care about it.
Re:Initialization in C++ is bonkers (2017) by loeg on Thursday May 15, 2025 @10:29PM (#44001315)
Again, I'm not opposed to the idea, it just seems more challenging logistically.
Re:Initialization in C++ is bonkers (2017) by motorest on Friday May 16, 2025 @04:55AM (#44003181)
> I don't really care if it isn't portable.

You don't care because your job is not to ensure that a new release of C++ doesn't break production code. You gaze at your navel and pretend that's the universe everyone is bound to. But there are others using C++, and using it in production software. Some of them care, and your subjective opinions don't have an impact in everyone else's requirements.

> I only have to work with Clang, personally.

Read Clang's manual and check what compiler flags you need to flip to get that behavior. It's already there.

Re:Initialization in C++ is bonkers (2017) by loeg on Friday May 16, 2025 @03:54PM (#44009223)
Lmao. You've misread both of my upthread comments and have somehow arrived at the conclusion that this justifies personal attacks. There's just no discussion to be had here.
Re:Initialization in C++ is bonkers (2017) by TuxSH on Friday May 16, 2025 @06:25AM (#44003673)
Gcc already has [[gnu::uninitialized]] (clang doesn't, AFAIK), as well as -ftrivial-auto-var-init=pattern which exactly matches the new C++26 semantics, if I'm not mistaken
Re:Initialization in C++ is bonkers (2017) by loeg on Friday May 16, 2025 @03:56PM (#44009234)
> -ftrivial-auto-var-init=pattern

I believe this only helps for trivial automatic variables; not non-trivial automatic variables (structs/classes) that contain uninitialized trivial members.

Re:Initialization in C++ is bonkers (2017) by TuxSH on Sunday May 18, 2025 @09:27AM (#44021278)
Ah, you're right, thanks for correcting me! This also doesn't apply to heap-allocated variables, though I think p2795r2 should cover all these cases.

I wonder if (for stack variables) this is due to an implementation detail in the compiler. After all, non-trivial classes have 'actual' constructors that run and that is supposed to initialize their respective class instances...