[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    [cfe-dev] temporary object with static storage duration materialization regression with -std=c++17 a
From:       Language Lawyer via cfe-dev <cfe-dev () lists ! llvm ! org>
Date:       2019-01-31 13:25:00
Message-ID: c1593c04-d950-5eee-459d-56ce834bfdf3 () gmail ! com
[Download RAW message or body]

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. \
https://godbolt.org/z/dbnpM9

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. \
_______________________________________________ cfe-dev mailing list
cfe-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic