Thread: build gcc warning

build gcc warning

From
Pavel Stehule
Date:
Hi

I got new warning

 -o session.bc session.c
analyze.c: In function ‘transformStmt’:
analyze.c:550:21: warning: ‘sub_rteperminfos’ may be used uninitialized [-Wmaybe-uninitialized]
  550 |         List       *sub_rteperminfos;
      |                     ^~~~~~~~~~~~~~~~

<-->if (isGeneralSelect)
<-->{
<--><-->sub_rtable = pstate->p_rtable;
<--><-->pstate->p_rtable = NIL;
<--><-->sub_rteperminfos = pstate->p_rteperminfos;
<--><-->pstate->p_rteperminfos = NIL;
<--><-->sub_namespace = pstate->p_namespace;
<--><-->pstate->p_namespace = NIL;
<-->}
<-->else
<-->{
<--><-->sub_rtable = NIL;<-><-->/* not used, but keep compiler quiet */
<--><-->sub_namespace = NIL;
           --- missing sub_rteperminfos
<-->}

Regards

Pavel

Re: build gcc warning

From
Tom Lane
Date:
Pavel Stehule <pavel.stehule@gmail.com> writes:
> I got new warning
> analyze.c: In function ‘transformStmt’:
> analyze.c:550:21: warning: ‘sub_rteperminfos’ may be used uninitialized
> [-Wmaybe-uninitialized]

A couple of buildfarm animals are warning about that too ... but
only a couple.

            regards, tom lane



Re: build gcc warning

From
Andres Freund
Date:
Hi,

On 2022-12-27 01:55:06 -0500, Tom Lane wrote:
> Pavel Stehule <pavel.stehule@gmail.com> writes:
> > I got new warning
> > analyze.c: In function ‘transformStmt’:
> > analyze.c:550:21: warning: ‘sub_rteperminfos’ may be used uninitialized
> > [-Wmaybe-uninitialized]
> 
> A couple of buildfarm animals are warning about that too ... but
> only a couple.

I'm a bit confused by gcc getting confused here - the condition for
sub_rteperminfos getting initialized and used are the same. Most of the time
the maybe-uninitialized logic seems to be better than this.

Greetings,

Andres Freund



Re: build gcc warning

From
Tom Lane
Date:
Andres Freund <andres@anarazel.de> writes:
> On 2022-12-27 01:55:06 -0500, Tom Lane wrote:
>> A couple of buildfarm animals are warning about that too ... but
>> only a couple.

> I'm a bit confused by gcc getting confused here - the condition for
> sub_rteperminfos getting initialized and used are the same. Most of the time
> the maybe-uninitialized logic seems to be better than this.

Apparently the key phrase there is "most of the time" ;-).

I see that we've had an equally "unnecessary" initialization of the
sibling variable sub_rtable for a long time, so the problem's been
there for some people before.  I made it initialize sub_rteperminfos
the same way.

            regards, tom lane