frederick-vs-ja wrote: > That's right. For example, the standard would require that a standard-layout > `std::unique_ptr<int>` has the same representation as `int *` (assuming the > obvious implementation), and it was not considered practical to change the > representation of all pointers for compatibility reasons.
However, even if we make `std::unique_ptr<int>` non-standard-layout, as long as the `int*` subobject is at offset 0, it's still well-defined to access the `int*` subobject via `*std::launder(reinterpret_cast<int*>(&up))`. I'm not sure whether merely requiring `launder` would be safe enough. I think a "safer" way (defending against `reinterpret_cast`) would be making the `int*` subobject (and its friends) at some positive offset. But this is theoretically orthogonal to the standard-layout property. https://github.com/llvm/llvm-project/pull/151652 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits