[cfe-dev] temporary object with static storage duration materialization regression with -std=c++17 and above?
Language Lawyer via cfe-dev
cfe-dev at lists.llvm.org
Thu Jan 31 05:25:00 PST 2019
For a top-level lvalue reference to const initialized by a prvalue:
const int& ri = 5;
the object with the value `5` is created in the .rodata section with -std=c++14 and below (which is expected) and in .data with -std=c++17 and above.
I don't see any changes between the standards justifying this.
My guess that clang does not adjust the type of the prvalue as described in [dcl.init.ref]/5.2
> If the converted initializer is a prvalue, its type T4 is adjusted to type “cv1 T4” ([conv.qual]) and the temporary materialization conversion is applied.
With a prvalue initializer of a non-reference-compatible type — `const int& ri = 5.0;` — the object is always created in .rodata.
More information about the cfe-dev