Steps to Reproduce: 1) C declaration: `int * const x[];` 2) Compile, run with GDB and execute GDB command `info variables` Actual Results: `int * constx[1];` (no space between `const` and name `x`) Expected Results: `int * const x[1];` (space between `const` and name `x`) Environment: * Linux 5.8.0-63-generic #71~20.04.1-Ubuntu SMP Thu Jul 15 17:46:08 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux * Both: gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) and clang version 10.0.0-4ubuntu1 * GNU gdb (GDB) 12.0.50.20210722-git Additional Info: Seems to be some combination of the `const` appearing after the `*` and the fact that this is an array. The following all output as expected: * `int * const x;` * `int * x[];` * `int const x[];`
Created attachment 13569 [details] Possible fix. Still in testing here, but if it passes I'll post this to the m/l.
https://sourceware.org/pipermail/gdb-patches/2021-July/181133.html
The master branch has been updated by Andrew Burgess <aburgess@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=77791f9c21ec05423db6724a3be543f2cb6e5822 commit 77791f9c21ec05423db6724a3be543f2cb6e5822 Author: Andrew Burgess <andrew.burgess@embecosm.com> Date: Mon Jul 26 17:29:05 2021 +0100 gdb: fix missing space in some info variables output Fixes PR gdb/28121. When a user declares an array like this: int * const foo_1[3]; And in GDB the user does this: (gdb) info variables foo All variables matching regular expression "foo": File test.c: 1: int * constfoo_1[3]; Notice the missing space between 'const' and 'foo_1'. This is fixed in c_type_print_varspec_prefix (c-typeprint.c) by passing through the flag that indicates if a trailing space is needed, rather than hard coding the flag to false as we currently do. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28121
I believe this issue should now be fixed.
*** Bug 14696 has been marked as a duplicate of this bug. ***