Re: [PATCH 1/2] gdb: remove dead code in make_pointer_type and make_reference_type

Simon Marchi <[email protected]> Mon, 3 Aug 2026 10:50:47 -0400
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
On 8/3/26 10:35 AM, Tankut Baris Aktemur wrote:
> At the end of `make_pointer_type` and `make_reference_type`, GDB
> updates the length of every type in the chain.  This is practically
> dead code, because if we reach this point, we must have allocated a
> new type.  After a new allocation, the chain contains only the
> newly-created type itself.  See in `type_allocator::new_type ()`:
> 
>   type->chain = type;   /* Chain back to itself.  */
> 
> That is, we always have `ntype == ntype->chain`.  Therefore, the loop
> can never be entered.  Remove it.
> 
> In `make_reference_type`, we also remove `*reftype = ntype;`, because
> a few lines above the assignment was already made.  This is repeated
> code.

Thanks, this LGTM.

Approved-By: Simon Marchi <[email protected]>

Simon