From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: rename YYSTACKDATA in generated parsers
Date: Thu, 8 Oct 2026 10:00:54 -0400 [thread overview]
Message-ID: <6d524653-b2d7-470f-aa5a-87c3fafd5030@polymtl.ca> (raw)
In-Reply-To: <20261007140014.2488030-1-simon.marchi@polymtl.ca>
On 10/7/26 9:55 AM, simon.marchi@polymtl.ca wrote:
> From: Simon Marchi <simon.marchi@polymtl.ca>
>
> When building with byacc and -flto -Werror=odr, we get:
>
> ada-exp-parser-gen.c.tmp:1552:3: error: type 'struct YYSTACKDATA' violates the C++ One Definition Rule [-Werror=odr]
> c-exp-parser-gen.c.tmp:3732:3: note: a different type is defined in another translation unit
> ada-exp-parser-gen.c.tmp:1546:30: note: the first difference of corresponding definitions is field 'l_base'
> c-exp-parser-gen.c.tmp:3726:28: note: a field of same name but different type is defined in another translation unit
> ada-exp-parser-gen.c.tmp:1552:3: note: type name 'ada_exp_parser_YYSTYPE' should match type name 'c_exp_parser_YYSTYPE'
>
> The byacc generated parsers define this type:
>
> typedef struct {
> unsigned stacksize;
> YYINT *s_base;
> YYINT *s_mark;
> YYINT *s_last;
> YYSTYPE *l_base;
> YYSTYPE *l_mark;
> ...
> } YYSTACKDATA;
>
> Since YYSTYPE represents a different type in each parser (it is renamed
> to {prefix}_YYSTYPE by post-process-parser-output.sh), then YYSTACKDATA
> is also a different type in each parser, which leads to ODR violations.
>
> This is a regression from my patch that removed yy-remap.h (d3d68d798e0c
> "gdb: let the parser and lexer generators prefix their symbols").
> yy-remap.h remapped YYSTACKDATA, since commit df940f8bb348 ("gdb: Fix an
> ODR warning with byacc with GDB_YY_REMAP") which fixed this exact
> problem.
>
> Fix it by adding YYSTACKDATA to the renames done in
> post-process-parser-output.sh, alongside YYSTYPE and friends.
>
> This is a master-only bug, no need to cherry-pick to gdb-18-branch.
>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34712
> Change-Id: I6332bd0edc6619434f67cccef463cd21e96e3251
Sam confirmed on Bugzilla that the patch fixes the problem, so I went
ahead and pushed it.
Simon
prev parent reply other threads:[~2026-10-08 14:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 13:55 simon.marchi
2026-10-08 14:00 ` Simon Marchi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6d524653-b2d7-470f-aa5a-87c3fafd5030@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox