Bug 28121 - `info variables` for `int * const x[]` gives `int * constx[1]` (no space between `const` and name)
Summary: `info variables` for `int * const x[]` gives `int * constx[1]` (no space betw...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: HEAD
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 14696 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-07-22 13:19 UTC by Vlad
Modified: 2023-12-31 15:26 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Possible fix. (1.06 KB, patch)
2021-07-26 16:36 UTC, Andrew Burgess
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vlad 2021-07-22 13:19:58 UTC
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[];`
Comment 1 Andrew Burgess 2021-07-26 16:36:15 UTC
Created attachment 13569 [details]
Possible fix.

Still in testing here, but if it passes I'll post this to the m/l.
Comment 3 Sourceware Commits 2021-07-28 09:21:03 UTC
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
Comment 4 Andrew Burgess 2021-07-28 09:22:13 UTC
I believe this issue should now be fixed.
Comment 5 Hannes Domani 2023-12-31 15:26:45 UTC
*** Bug 14696 has been marked as a duplicate of this bug. ***