3 ms·
Sure, but it's unclear what the benefit of leaving auto C++ objects uninitialized is.
by loeg 8y ago
Sure, but it's unclear what the benefit of leaving auto C++ objects uninitialized is.
- eridius 8y agoIIRC, auto C++ objects aren't uninitialized, they're default-initialized, but said default-initialization may leave them with uninitialized fields. I would hope that this new automatic variable initialization would also apply to those fields of default-initialized auto C++ objects.
- kazinator 8y agoBuilt-in types like int are also "object"; only C++ class objects can have constructors that initialize them.
- olliej 8y agoAuto declarations don’t mean uninitialised, they get default initialisation, which for many types means “undefined”.
- loeg 8y agoI should have been more clear. What's the benefit of leaving automatic storage C++ object memory uninitialized?
- saagarjha 8y agoIt's fast?
- loeg 8y agoThe proposal would already accepti a performance tradeoff to initialize memory of uninitialized "trivial" variables. I'm not sure why you would want to draw a line in the sand at trivial variables only. What makes non-trivial uninitialized object memory higher penalty or lower risk?