Re: warning: dereferencing type-punned pointer - Mailing list pgsql-hackers

From Tom Lane
Subject Re: warning: dereferencing type-punned pointer
Date
Msg-id 1254018.1721844589@sss.pgh.pa.us
Whole thread Raw
In response to Re: warning: dereferencing type-punned pointer  (Peter Eisentraut <peter@eisentraut.org>)
Responses Re: warning: dereferencing type-punned pointer
Re: warning: dereferencing type-punned pointer
List pgsql-hackers
Peter Eisentraut <peter@eisentraut.org> writes:
> On 24.07.24 16:05, Tom Lane wrote:
>> I'm not very thrilled with these changes.  It's not apparent why
>> your compiler is warning about these usages of IsA and not any other
>> ones,

> I think one difference is that normally IsA is called on a Node * (since 
> you call IsA to decide what to cast it to), but in this case it's called 
> on a pointer that is already of type ErrorSaveContext *.

Hmm.  But there are boatloads of places where we call IsA on a
pointer of type Expr *, or sometimes other things.  Why aren't
those triggering the same warning?

> I think here you could just bypass the SOFT_ERROR_OCCURRED macro:
> -       if (SOFT_ERROR_OCCURRED(&jsestate->escontext))
> +       if (jsestate->escontext.error_occurred)

Perhaps.  That's a bit sad because it's piercing a layer of
abstraction.  I do not like compiler warnings that can't be
gotten rid of without making the code objectively worse.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: proposal: schema variables
Next
From: Peter Eisentraut
Date:
Subject: Re: [18] Policy on IMMUTABLE functions and Unicode updates