When compiling the below source code #include <string> template <typename = void> struct T { static constexpr std::string value{}; }; void f() { T<>::value; } the compiler fails on the line in f() with the following error referring to the members of the std::string being private: <source>:5:34: error: 'std::__cxx11::basic_string<char>::<unnamed union> std::__cxx11::basic_string<char>::<anonymous>' is private within this context 5 | static constexpr std::string value{}; | ^~~~~ In file included from /cefs/b6/b615954805438726f22a60c9_converted_gcc-15.2.0/include/c++/15.2.0/string:56, from <source>:1: /cefs/b6/b615954805438726f22a60c9_converted_gcc-15.2.0/include/c++/15.2.0/bits/basic_string.h:220:7: note: declared private here 220 | union | ^~~~~ <source>:5:34: error: 'char std::__cxx11::basic_string<char>::<unnamed union>::_M_local_buf [16]' is private within this context 5 | static constexpr std::string value{}; | ^~~~~ /cefs/b6/b615954805438726f22a60c9_converted_gcc-15.2.0/include/c++/15.2.0/bits/basic_string.h:222:26: note: declared private here 222 | _CharT _M_local_buf[_S_local_capacity + 1]; | ^~~~~~~~~~~~ The same code works fine in Clang. Checked with `-std=c++26`. https://godbolt.org/z/844x68798
Note this is most likely a dup of either PR 109576, bug 96716 or PR 97740 (or all 3 are dups of each other).
yep, let's mark this one as a dup *** This bug has been marked as a duplicate of bug 97740 ***