https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126088
Bug ID: 126088
Summary: String literals in annotations fail to reflect
Product: gcc
Version: 16.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: max.orth96 at gmail dot com
Target Milestone: ---
Created attachment 64922
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64922&action=edit
Preprocessed minimal example
Putting a const char */string literal through an annotation causes the string
to not reflect. Compilation fails with "'reflect_constant' failed". Defining
a char array and assigning a string literal to it does successfully reflect.
compile command: ~/gcc16/bin/g++ --std=c++26 -freflection ../test_strings.cpp
-o test_strings
Compiler output (with -v):
Using built-in specs.
COLLECT_GCC=/home/max/gcc16/bin/g++
COLLECT_LTO_WRAPPER=/home/max/gcc16/libexec/gcc/x86_64-pc-linux-gnu/16.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/home/max/gcc16/
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.1.1 20260629 (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++26' '-freflection' '-o'
'test_strings' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/home/max/gcc16/libexec/gcc/x86_64-pc-linux-gnu/16.1.1/cc1plus -E -quiet -v
-imultiarch x86_64-linux-gnu -D_GNU_SOURCE ../test_strings.cpp -mtune=generic
-march=x86-64 -std=c++26 -freflection -fpch-preprocess -o test_strings.ii
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/home/max/gcc16/lib/gcc/x86_64-pc-linux-gnu/16.1.1/include-fixed/x86_64-linux-gnu"
ignoring nonexistent directory
"/home/max/gcc16/lib/gcc/x86_64-pc-linux-gnu/16.1.1/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/home/max/gcc16/lib/gcc/x86_64-pc-linux-gnu/16.1.1/../../../../include/c++/16.1.1
/home/max/gcc16/lib/gcc/x86_64-pc-linux-gnu/16.1.1/../../../../include/c++/16.1.1/x86_64-pc-linux-gnu
/home/max/gcc16/lib/gcc/x86_64-pc-linux-gnu/16.1.1/../../../../include/c++/16.1.1/backward
/home/max/gcc16/lib/gcc/x86_64-pc-linux-gnu/16.1.1/include
/usr/local/include
/home/max/gcc16/include
/home/max/gcc16/lib/gcc/x86_64-pc-linux-gnu/16.1.1/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++26' '-freflection' '-o'
'test_strings' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/home/max/gcc16/libexec/gcc/x86_64-pc-linux-gnu/16.1.1/cc1plus -fpreprocessed
test_strings.ii -quiet -dumpbase test_strings.cpp -dumpbase-ext .cpp
-mtune=generic -march=x86-64 -std=c++26 -version -freflection -o test_strings.s
GNU C++26 (GCC) version 16.1.1 20260629 (x86_64-pc-linux-gnu)
compiled by GNU C version 16.1.1 20260629, GMP version 6.3.0, MPFR
version 4.2.1, MPC version 1.3.1, isl version isl-0.26-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 7bdbadb239fadd1649dbb1d4f1ac6761
../test_strings.cpp: In function ‘int main()’:
../test_strings.cpp:42:47: error: uncaught exception of type
‘std::meta::exception’; ‘what()’: ‘reflect_constant failed’
42 | char const * strTest2 = [: GetAttr(^^foo) :];
| ^~
../test_strings.cpp:45:50: error: uncaught exception of type
‘std::meta::exception’; ‘what()’: ‘reflect_constant failed’
45 | char const * strTest3 = [: GetAttr(^^foobar) :];
| ^~
../test_strings.cpp:48:52: error: uncaught exception of type
‘std::meta::exception’; ‘what()’: ‘reflect_constant failed’
48 | char const * strTest4 = [: GetAttr(^^constbar) :];
| ^~