Compiler warning with 'fast' variable

Started by Bruce Momjianabout 17 years ago5 messageshackers
Jump to latest
#1Bruce Momjian
bruce@momjian.us

Any idea why I am seeing this warning with the new pg_start_backup()
'fast' flag?

xlog.c:6917: warning: variable `fast' might be clobbered by
`longjmp' or `vfork'

The line is in a PG_ENSURE_ERROR_CLEANUP() block. This is with gcc
version 2.95.3.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#1)
Re: Compiler warning with 'fast' variable

Bruce Momjian <bruce@momjian.us> writes:

Any idea why I am seeing this warning with the new pg_start_backup()
'fast' flag?

xlog.c:6917: warning: variable `fast' might be clobbered by
`longjmp' or `vfork'

The line is in a PG_ENSURE_ERROR_CLEANUP() block. This is with gcc
version 2.95.3.

That's pretty bizarre --- I don't see it here with gcc 2.95.3,
and there is no reason for such a warning to appear on a variable
that isn't changed during the function.

We could stick a volatile on it but I'd like to find out why this
particular variable seems to need that.

regards, tom lane

#3Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#2)
Re: Compiler warning with 'fast' variable

Tom Lane wrote:

Bruce Momjian <bruce@momjian.us> writes:

Any idea why I am seeing this warning with the new pg_start_backup()
'fast' flag?

xlog.c:6917: warning: variable `fast' might be clobbered by
`longjmp' or `vfork'

The line is in a PG_ENSURE_ERROR_CLEANUP() block. This is with gcc
version 2.95.3.

That's pretty bizarre --- I don't see it here with gcc 2.95.3,
and there is no reason for such a warning to appear on a variable
that isn't changed during the function.

We could stick a volatile on it but I'd like to find out why this
particular variable seems to need that.

You ready for this; changing 'bool' to 'int' supressed the warning:

int fast = PG_GETARG_BOOL(1);

Using 'char' returns the warning. Changing the assignment to 'true'
also fixes it:

bool fast = true;

This also generates no warning about longjmp:

bool fast = PG_GETARG_TEXT(1);

No warning here either:

bool fast = (bool) PG_GETARG_DATUM(0);

This generates the warning:

bool fast = ((bool) ((bool) (PG_GETARG_DATUM(1)) != 0));

This does not:

bool fast = (bool) (PG_GETARG_DATUM(1) != 0);

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#3)
Re: Compiler warning with 'fast' variable

Bruce Momjian <bruce@momjian.us> writes:

Tom Lane wrote:

We could stick a volatile on it but I'd like to find out why this
particular variable seems to need that.

You ready for this; changing 'bool' to 'int' supressed the warning:
int fast = PG_GETARG_BOOL(1);

Well, that's a compiler bug :-(. Probably platform-specific, too,
which is why I don't see it on HPPA.

I think that the above variant is the least ugly of the alternatives
you show as working, and definitely less ugly than plastering volatile
on it.

regards, tom lane

#5Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#4)
Re: Compiler warning with 'fast' variable

Tom Lane wrote:

Bruce Momjian <bruce@momjian.us> writes:

Tom Lane wrote:

We could stick a volatile on it but I'd like to find out why this
particular variable seems to need that.

You ready for this; changing 'bool' to 'int' supressed the warning:
int fast = PG_GETARG_BOOL(1);

Well, that's a compiler bug :-(. Probably platform-specific, too,
which is why I don't see it on HPPA.

I think that the above variant is the least ugly of the alternatives
you show as working, and definitely less ugly than plastering volatile
on it.

Well, let's leave it alone and see if anyone else find it; I can mask
it on my end.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +