From: Andrew Burgess <aburgess@redhat.com>
To: Keith Seitz <keiths@redhat.com>, Kevin Buettner <kevinb@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2] Add infcall support for C++ constructor-style expressions
Date: Thu, 17 Sep 2026 15:41:16 +0100 [thread overview]
Message-ID: <87bj9waqk3.fsf@redhat.com> (raw)
In-Reply-To: <c951bd06-a87f-4f51-9b83-8eb2aeef1309@redhat.com>
Keith Seitz <keiths@redhat.com> writes:
> Hi,
>
> On 6/26/26 5:06 PM, Kevin Buettner wrote:
>>
>> Claude found this problem...
>> > (gdb) file /tmp/test_c
>> Reading symbols from /tmp/test_c...
>> (gdb) start
>> Temporary breakpoint 1 at 0x40044a: file /tmp/test_c.c, line 2.
>> Starting program: /tmp/test_c
>>
>> [Thread debugging using libthread_db enabled]
>> Using host libthread_db library "/lib64/libthread_db.so.1".
>>
>> Temporary breakpoint 1, main () at /tmp/test_c.c:2
>> 2 int main() { struct S s = {42}; return s.x; }
>> (gdb) print typeof(struct S)(42)
>> /home/kevinb-claude/binutils-gdb-patch-review/gdb/eval.c:1885: internal-error: evaluate_funcall: Assertion `exp->language_defn->la_language == language_cplus' failed.
>> A problem internal to GDB has been detected,
>> further debugging may prove unreliable.
>> ----- Backtrace -----
>> 0x51e699 gdb_internal_backtrace_1
>> /home/kevinb-claude/binutils-gdb-patch-review/gdb/bt-utils.c:122
>> 0x51e699 _Z22gdb_internal_backtracev
>> /home/kevinb-claude/binutils-gdb-patch-review/gdb/bt-utils.c:173
>> 0x9fb874 internal_vproblem
>> /home/kevinb-claude/binutils-gdb-patch-review/gdb/utils.c:434
>> 0x9fbd38 _Z15internal_verrorPKciS0_P13__va_list_tag
>> /home/kevinb-claude/binutils-gdb-patch-review/gdb/utils.c:514
>> 0xb6cea1 _Z18internal_error_locPKciS0_z
>> /home/kevinb-claude/binutils-gdb-patch-review/gdbsupport/errors.cc:57
>> 0x67e31c _ZN4expr14type_operation16evaluate_funcallEP4typeP10expression6nosideRKSt6vectorISt10unique_ptrINS_9operationESt14default_deleteIS8_EESaISB_EE
>> ...
>>
>
> Thanks for the report.
>
> The root cause is that the C++-only gate lived only in the lexer, but
> `typeof(T)` is a separate `type_exp` production. So in C, `typeof(struct
> S)(42)` still matched the general `type_exp '(' arglist ')'` rules,
> built a `funcall_operation`, and hit the `language_cplus` assert in
> `type_operation::evaluate_funcall`.
>
> The fix is to mirror the lexer gate in those parser actions: if the
> language is not C++, throw an error:
>
> (gdb) print typeof(struct S)(42)
> Constructor-style casts are only valid in C++
>
> I left the `type_exp`-based productions in place rather than splitting
> out a dedicated ctor non-terminal; the language check closes the hole
> Claude found without that larger grammar change. I'm happy to revisit
> the shift/reduce side separately if consensus is reached. [This is the
> direction a previous review steered me, and I am happy to revisit that
> initial review recommendation.]
If that was my review, then please do feel free to ignore it. My review
comments are not always based on tested code, usually just my thoughts
when looking through the patch, that doesn't always mean the thoughts
are any good :)
Thanks,
Andrew
next prev parent reply other threads:[~2026-09-17 14:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 19:17 [PATCH] " Keith Seitz
2026-03-27 5:50 ` Eli Zaretskii
2026-04-21 13:41 ` Andrew Burgess
2026-04-21 18:13 ` Keith Seitz
2026-04-27 16:43 ` [PATCH v2] " Keith Seitz
2026-06-19 17:21 ` Keith Seitz
2026-06-27 0:06 ` Kevin Buettner
2026-07-29 17:44 ` Keith Seitz
2026-09-17 14:41 ` Andrew Burgess [this message]
2026-09-17 16:05 ` Keith Seitz
2026-09-17 15:10 ` Andrew Burgess
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=87bj9waqk3.fsf@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=keiths@redhat.com \
--cc=kevinb@redhat.com \
/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