Re: PG_TRY()/CATCH() in a loop reports uninitialized variables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Adam Lee <ali(at)pivotal(dot)io>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Ning Yu <nyu(at)pivotal(dot)io>
Subject: Re: PG_TRY()/CATCH() in a loop reports uninitialized variables
Date: 2019-08-08 14:47:47
Message-ID: 25875.1565275667@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Adam Lee <ali(at)pivotal(dot)io> writes:
> That's fine actually, but if we put the PG_TRY()/CATCH() in a loop, high
> version gcc might complain.

I'd be inclined to say "so don't do that then". Given this interpretation
(which sure looks like a bug to me, gcc maintainers' opinion or no),
you're basically going to have to mark EVERYTHING in that function
volatile. Better to structure the code so you don't have to do that,
which would mean not putting the TRY and the loop in the same level
of function.

I've seen other weird-maybe-bug gcc behaviors in the vicinity of
setjmp calls, too, which is another factor that pushes me not to
want to assume too much about what you can do in the same function
as a TRY call.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-08-08 14:56:33 Re: clean up obsolete initdb locale handling
Previous Message Peter Eisentraut 2019-08-08 14:27:25 clean up obsolete initdb locale handling