Re: [PATCH v2] gdb: prefer lhs type's address spaces/classes in check_typedef

Keith Seitz <[email protected]> Thu, 30 Jul 2026 11:12:44 -0700
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
On 7/30/26 2:13 AM, Tankut Baris Aktemur wrote:
> In commit 92fdad7 "gdb: convert type instance flags to bitfields",
> `operator|=` of type_instance_flags required the address space and
> address class values of left-hand-side to be zero.  This introduced
> the following bug (thanks to Keith Seitz for reporting it at
> https://inbox.sourceware.org/gdb-patches/[email protected]/T/#u):
> 
> So, the assertion in operator|= was wrong.  The outer type, which is
> the left-hand-side in this case, should preserve its values if they
> are non-zero.  The right-hand-side values are used, if lhs values are
> zero.  Fix the bug accordingly.
> 
> Furthermore, rename operator|= to "merge".  Type instance flags are no
> longer stored as a bitmask value, but rather as a struct.  Having an
> operator like |= gives the wrong impression that we are doing a
> bitmask OR.  Using a method makes the intention clearer.
> 
> Include a regression test.

This LGTM. Thank you very much!

Reviewed-By: Keith Seitz <[email protected]>

Keith