@denbvk@Jonathan_Blow No compiler on earth had optimizations that disallow aliasing by type. Even today MSVC does not implement any optimization that makes use of strict aliasing. Back then more than ever you had to program so that the compiler could output the code you wanted.
@Jonathan_Blow@denbvk I think when he the LLM says aliasing UB it's maybe taking about strict aliasing rules in C++, which didn't even exist back then and (obviously) did not apply.
@SebAaltonen I expected it to be POD/standard layout, but, in terms of C++ standard, dereferencing that pointer is UB, regardless if it's reading or writing.
The only standard alternative to avoid value-initializing the whole thing is memcpy really, which is more verbose unfortunately.
@SebAaltonen Well, it's not lifetime which confuses me. As you said, within the expression lifetime is extended.
What I don't expect is for that to compile, e.g. this simple example fails: https://t.co/ro9WT02tKo
Maybe you can tell which ctor is being used in your case?
@SebAaltonen Are you using std::span? Because that doesn't have a constructor getting std::initializer_list, for good reasons. I don't think this should compile with an rvalue initializer_list.