News for hackers. Stuff that matters.
Re:Fun with C++26 reflection: Keyword Arguments by badmintonbaseba on Thursday February 20, 2025 @08:44AM (#43114542)
My gripe was not the form of initialization of the elements, but forming `b.a1` before `b`'s lifetime has started. It hasn't started before all of the elements are initialized.
Re:Fun with C++26 reflection: Keyword Arguments by drysine on Thursday February 20, 2025 @02:22PM (#43118943)
But do we need the lifetime of b to be started? Isn't it enough that a1's lifetime is started? Taking of address of a1 happens after that. [0]

Upd:

There is an interesting sentence in [class.cdtor] but I don't think it applies here because B has no constructors:

"For an object with a non-trivial constructor, referring to any non-static member or base class of the object before the constructor begins execution results in undefined behavior."[1]

[0] https://eel.is/c++draft/dcl.init.aggr#7

[1] https://eel.is/c++draft/class.cdtor#1