miniscule compiler barf in pg_ctl.c

Started by Dann Corbitover 21 years ago2 messages
#1Dann Corbit
DCorbit@connx.com

I have seen this before with other compilers. The latest MINGW GCC
compiler does not like a goto label with no statements following.
pg_ctl.c: In function `pgwin32_ServiceMain':
pg_ctl.c:991: error: label at end of compound statement
make[3]: *** [pg_ctl.o] Error 1
make[3]: Leaving directory `/u/postgresql-snapshot/src/bin/pg_ctl'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/u/postgresql-snapshot/src/bin'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/u/postgresql-snapshot/src'
make: *** [all] Error 2

Fix is simple, add an empty statement:

switch (ret)
{
case WAIT_OBJECT_0: /* shutdown event */
kill(postmasterPID,SIGINT);
WaitForSingleObject(postmasterProcess,INFINITE);
break;

case (WAIT_OBJECT_0+1): /* postmaster went down */
break;

default:
; /* <<<<<<<<<< Just a semicolon added here <<<<<<<<<<<< */
/* assert(false); */
}

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dann Corbit (#1)
Re: miniscule compiler barf in pg_ctl.c

"Dann Corbit" <DCorbit@connx.com> writes:

default:
; /* <<<<<<<<<< Just a semicolon added here <<<<<<<<<<<< */
/* assert(false); */
}

Personally I prefer writing

default:
break;

Switch branches that don't have break or return at the end are trouble
waiting to happen, compiler glitches or no ...

Patched, thanks!

regards, tom lane