Further news on Clang - spurious warnings - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Further news on Clang - spurious warnings
Date
Msg-id CAEYLb_Ve0g-nmh6g=Pq45e_eMHJdLwvyftQduf361Bd=2uwZhQ@mail.gmail.com
Whole thread Raw
Responses Re: Further news on Clang - spurious warnings
List pgsql-hackers
I'm happy to report that thanks to some persistent complaining on my
part, the one outstanding issue when building Postgres with Clang -
the spurious warnings that occured as a result of it being statically
detected that there are assignments past what appears to be the end of
a single element array at the end of a struct - has been fixed in a
recent revision. Now, the only warning that remains is that same,
annoying Flex related bug also seen with GCC that we can't seem to do
anything about, because the Flex people refuse to acknowledge that
it's a bug.

However, at least when you see this warning when using Clang, you get
to see a comment beside the declaration that hints that the warning is
spurious:

[peter@laptop postgresql]$ /home/peter/build/Release/bin/clang -O2
-Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wendif-labels -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-error -I. -I. -Isrc/include
-D_GNU_SOURCE   -c -o gram.o src/backend/parser/gram.c
In file included from gram.y:12949:
scan.c:16246:23: warning: unused variable 'yyg' [-Wunused-variable]   struct yyguts_t * yyg = (struct
yyguts_t*)yyscanner;/* This var 
may be unused depending upon options. */                     ^
1 warning generated.


This is not the case with GCC 4.6:

[peter@laptop postgresql]$ gcc -O2 -Wall -Wmissing-prototypes
-Wpointer-arith -Wdeclaration-after-statement -Wendif-labels
-Wformat-security -fno-strict-aliasing -fwrapv -Wno-error -I. -I.
-Isrc/include -D_GNU_SOURCE   -c -o gram.o src/backend/parser/gram.c
In file included from gram.y:12949:0:
scan.c: In function ‘yy_try_NUL_trans’:
scan.c:16246:23: warning: unused variable ‘yyg’ [-Wunused-variable]

--
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: patch: move dumpUserConfig call in dumpRoles function of pg_dumpall.c
Next
From: Tom Lane
Date:
Subject: Re: pgbench internal contention