https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110976
Bug ID: 110976 Summary: Cryptic error message when incorrectly dereferencing a pointer in an anonymous union Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: jesper.oqvist at gmail dot com Target Milestone: --- The following program gives me a cryptic error message when compiled with GCC 14 snapshot 20230806: struct S { union { struct S* x; }; }; struct S* f(struct S s) { return s.x.x; } Compiling this program with $HOME/opt/gcc-14/bin/gcc anon_union.c gives the error message below: anon_union.c: In function 'f': anon_union.c:4:13: error: 's.<U27b8>.x' is a pointer; did you mean to use '->'? 4 | return s.x.x; | ^ | -> I presume the <U27b8> part is how GCC names the anonymous union in struct S, but it seems like this could be formatted a bit nicer to make the error message easier to understand. Each time I re-run the compiler on the same program the part in angle brackets changes to another 5-letter string starting with U. Below is the gcc -v output: $HOME/opt/gcc-14/bin/gcc -v anon_union.c Using built-in specs. COLLECT_GCC=/home/jesper/opt/gcc-14/bin/gcc COLLECT_LTO_WRAPPER=/home/jesper/opt/gcc-14/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-14-20230806/configure --prefix=/home/jesper/opt/gcc-14 --disable-nls --disable-werror --disable-bootstrap --enable-languages=c,c++ Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 20230806 (experimental) (GCC) COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-' /home/jesper/opt/gcc-14/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/cc1 -quiet -v -imultiarch x86_64-linux-gnu anon_union.c -quiet -dumpdir a- -dumpbase anon_union.c -dumpbase-ext .c -mtune=generic -march=x86-64 -version -o /tmp/ccsUEV7J.s GNU C17 (GCC) version 14.0.0 20230806 (experimental) (x86_64-pc-linux-gnu) compiled by GNU C version 11.4.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/home/jesper/opt/gcc-14/lib/gcc/x86_64-pc-linux-gnu/14.0.0/../../../../x86_64-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /home/jesper/opt/gcc-14/lib/gcc/x86_64-pc-linux-gnu/14.0.0/include /usr/local/include /home/jesper/opt/gcc-14/include /home/jesper/opt/gcc-14/lib/gcc/x86_64-pc-linux-gnu/14.0.0/include-fixed/x86_64-linux-gnu /home/jesper/opt/gcc-14/lib/gcc/x86_64-pc-linux-gnu/14.0.0/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. Compiler executable checksum: 020a05d35e6345424c620c1d2d7de9eb