``` gcc src.c -gdwarf-5 -o a.out && gdb a.out (gdb) b 13 Breakpoint 1 at 0x1170: file src.c, line 13. (gdb) run Starting program: a.out (gdb) expr z[0]._[0] = 1 gdb command line:1:1: error: size of array element is not a multiple of its alignment Compilation failed. (gdb) expr y[0]._[0] = 1 (gdb) expr x[0]._[0] = 1 gdb command line:1:1: error: alignment of array elements is greater than element size Compilation failed. ``` Running with the trunk gcc and the trunk gdb here and this fails.
Created attachment 15375 [details] src.c
This was originally reported on the gcc side (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113977) but the debug info seems correct. Since the default alignment is specified, it seems like gcc_convert_symbol is adding the wrong alignment for the struct which causes gcc to reject the array definition. The alignment of s7, s8, and s9 are all 1 since it has an array of char's.
I think this requires a combination fix, since the protocol doesn't allow for alignment. I'll comment on the gcc bug.
I have a patch.
The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f9771d0e80c3a98e865c7ee5139cadf9d73db436 commit f9771d0e80c3a98e865c7ee5139cadf9d73db436 Author: Tom Tromey <tom@tromey.com> Date: Tue Feb 20 17:15:03 2024 -0700 Synchronize GCC compile plugin headers This patch copies some changes to the compile headers from GCC's include/ directory. It is the gdb equivalent of the GCC commit bc0e18a9 -- however, while that commit also necessarily touched libcc1, this one of course does not. Tested by rebuilding and also running the gdb.compile tests. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31397
The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=91e15dbaf9d05747fab0d33e5af7ae69c983398a commit 91e15dbaf9d05747fab0d33e5af7ae69c983398a Author: Tom Tromey <tom@tromey.com> Date: Wed Feb 21 08:22:01 2024 -0700 Pass alignment when using GCC_C_FE_VERSION_2 When the GCC compiler plugin responds with GCC_C_FE_VERSION_2, gdb can use the new 'finish_record_with_alignment' method. This lets gdb pass alignment information to the compiler, which in turn fixes the test case included in this patch. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31397
Fixed.