Re: Compiler warning with 'fast' variable

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Compiler warning with 'fast' variable
Date: 2009-04-07 23:04:39
Message-ID: 200904072304.n37N4dH02328@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-04-07 23:09:33 Re: Compiler warning with 'fast' variable
Previous Message Tom Lane 2009-04-07 22:48:24 Re: Compiler warning with 'fast' variable