[Bug c++/110822] [13/14 Regression] ICE on constexpr initialized with non-constant expression also accepts-invalid

de34 at live dot cn gcc-bugzilla@gcc.gnu.org
Fri Jul 28 08:34:27 GMT 2023


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110822

Jiang An <de34 at live dot cn> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |de34 at live dot cn

--- Comment #3 from Jiang An <de34 at live dot cn> ---
This example is valid (or should be) for libstdc++.

Given `constexpr std::string text = "Some text here"s;` in namespace scope
("being a global variable"), the std::string object, which has static storage
duration, contains a pointer to its subobject, and doesn't hold any pointer to
a dynamically allocated storage.

Clang complains that the _M_construct function is not defined at the call point
so a call to it should make constant evalution fail. _M_construct is actually
defined later (in basic_string.tcc IIUC).

There's an unreolved CWG issue about this.
https://cplusplus.github.io/CWG/issues/2166.html


More information about the Gcc-bugs mailing list