GCC warning in back branches

Started by Thomas Munroabout 5 years ago4 messageshackers
Jump to latest
#1Thomas Munro
thomas.munro@gmail.com

Hi,

guc.c: In function ‘RestoreGUCState’:
guc.c:9455:4: error: ‘varsourceline’ may be used uninitialized in this
function [-Werror=maybe-uninitialized]
9455 | set_config_sourcefile(varname, varsourcefile, varsourceline);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I propose the attached.

Attachments:

0001-Fix-compiler-warning-in-back-branches.patchtext/x-patch; charset=US-ASCII; name=0001-Fix-compiler-warning-in-back-branches.patchDownload+2-1
#2Michael Paquier
michael@paquier.xyz
In reply to: Thomas Munro (#1)
Re: GCC warning in back branches

On Mon, Feb 15, 2021 at 02:15:51PM +1300, Thomas Munro wrote:

guc.c: In function ‘RestoreGUCState’:
guc.c:9455:4: error: ‘varsourceline’ may be used uninitialized in this
function [-Werror=maybe-uninitialized]
9455 | set_config_sourcefile(varname, varsourcefile, varsourceline);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I propose the attached.

We usually don't bother much about compilation warnings in stable
branches as long as they are not real bugs, and these are the oldest
stable ones. So why here? I would have patched the top of the
function if it were me, btw.
--
Michael

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Michael Paquier (#2)
Re: GCC warning in back branches

Michael Paquier <michael@paquier.xyz> writes:

On Mon, Feb 15, 2021 at 02:15:51PM +1300, Thomas Munro wrote:

I propose the attached.

We usually don't bother much about compilation warnings in stable
branches as long as they are not real bugs, and these are the oldest
stable ones. So why here? I would have patched the top of the
function if it were me, btw.

If somebody were running a buildfarm member with recent gcc
and -Werror, we'd pretty much have to fix it.

I'd say the real policy is that we don't worry about
uninitialized-variable warnings from old compiler versions,
on the theory that they're probably compiler shortcomings.
But I'd be inclined to fix anything from a current gcc version.

regards, tom lane

#4Thomas Munro
thomas.munro@gmail.com
In reply to: Michael Paquier (#2)
Re: GCC warning in back branches

On Mon, Feb 15, 2021 at 2:35 PM Michael Paquier <michael@paquier.xyz> wrote:

... I would have patched the top of the
function if it were me, btw.

I just copied the way it is coded in master (due to commit fbb2e9a0
which fixed this warning in 11+).