yxhuvud 1 day ago

The discussion about what should be the default behavior and of what should be the opt-in behavior is very different from what should be possible. It is definitely clear that in c++, it must be possible to not initialize variables.

Would it really be that unreasonable to have initialisation be opt-out instead of opt-in? You'd still have just as much control, but it would be harder to shoot yourself in the foot by mistake. Instead it would be slightly more easy to get programs that can be optimised.

1
frollogaston 1 day ago

C++ is supposed to be an extension of C, so I wouldn't expect things to be initialized by default, even though personally I'm using C++ for things where it'd be nice.

I'm more annoyed that C++ has some way to default-zero-init but it's so confusing that you can accidentally do it wrong. There should be only one very clear way to do this, like you have to put "= 0" if you want an int member to init to 0. If you're still concerned about safety, enable warnings for uninitialized members.

dwattttt 1 day ago

C++ is supposed to be an extension of <thing with bad default>, so I wouldn't expect <a good default>.

Things can change & grow, that's why we make new standards in the first place.

frollogaston 1 day ago

It'd be confusing for C++ to differ from C in how primitives work. If they want to evolve C too then sure.

frollogaston 23 hours ago

also there are compiler warnings for uninitialized variables

gpderetta 1 day ago

my_type my_var = {}; almost always does the right thing.

The almost is unfortunate.