Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Kevin Buettner <kevinb@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: tighten assertions in set_type_vptr_*
Date: Mon, 2 Feb 2026 13:15:10 -0500	[thread overview]
Message-ID: <ae05d7a7-aae5-4875-9ec9-6baff7c05d13@simark.ca> (raw)
In-Reply-To: <20260202103806.31b501b7@f42-mesa-1>



On 2026-02-02 12:38, Kevin Buettner wrote:
> On Mon, 26 Jan 2026 10:54:00 -0500
> Simon Marchi <simon.marchi@efficios.com> wrote:
> 
>> From: Simon Marchi <simon.marchi@efficios.com>
>> To: gdb-patches@sourceware.org
>> Cc: Simon Marchi <simon.marchi@polymtl.ca>
>> Subject: [PATCH] gdb: tighten assertions in set_type_vptr_*
>> Date: Mon, 26 Jan 2026 10:54:00 -0500
>>
>> From: Simon Marchi <simon.marchi@polymtl.ca>
>>
>> In C++, only structures and classes (represented by TYPE_CODE_STRUCT)
>> can participate in inheritance.  I therefore think it does not make
>> sense to allow for TYPE_CODE_UNION in set_type_vptr_basetype and
>> set_type_vptr_fieldno.  Remove the possibility for the type to be a
>> union in these functions.
>>
>> Also, for the same reason, add an assertion that checks the type of
>> basetype in set_type_vptr_basetype.
>>
>> I did not change the getters (internal_type_vptr_fieldno and
>> internal_type_vptr_basetype), because it seems like they are called by
>> code that handles similarly both structures and unions.  Making those
>> stricter would require adding conditions in those callers, which doesn't
>> look like an improvement.  For unions, they will correctly return an
>> "invalid" value.
>>
>> Change allocate_cplus_struct_type to not use set_type_vptr_fieldno to
>> initialize the field to -1, otherwise it would trip the assertion when
>> initializing for a union type.
> 
> Makes sense to me...
> 
> Approved-by: Kevin Buettner <kevinb@redhat.com>
> 

Pushed, thanks!

Simon

  reply	other threads:[~2026-02-02 18:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-26 15:54 Simon Marchi
2026-02-02 17:38 ` Kevin Buettner
2026-02-02 18:15   ` Simon Marchi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-01-23 19:22 simon.marchi

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=ae05d7a7-aae5-4875-9ec9-6baff7c05d13@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --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