Re: [HACKERS] gcc 4.6 -Wunused-but-set-variable
On ons, 2011-06-15 at 19:28 -0400, Tom Lane wrote: Peter Eisentraut pete...@gmx.net writes: I couldn't see a way good way of programming around this (perhaps in the second case, but it would get uselessly ugly), so perhaps just marking the variables as potentially unused would be appropriate? See patch. Of course this would break not only on non-gcc compilers, but old versions of gcc. I'd suggest a macro (cf PERL_UNUSED_DECL) and some version checks at the site of the macro declaration (perhaps the ones emitted by bison for its use of this construct will do). Non-GCC compilers would be fine, because we define away __attribute__ there anyway, but on GCC itself, you're right, the unused attribute is a bit more recent than ancient. Actually, casting to void, which is the convention we already use elsewhere, works for this, so done that way. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
[HACKERS] gcc 4.6 -Wunused-but-set-variable
Another set of new gcc 4.6 warnings: readfuncs.c: In function ‘_readCaseWhen’: readfuncs.c:875:567: warning: variable ‘token’ set but not used [-Wunused-but-set-variable] readfuncs.c: In function ‘_readFromExpr’: readfuncs.c:1159:568: warning: variable ‘token’ set but not used [-Wunused-but-set-variable] read.c: In function ‘nodeTokenType’: read.c:222:8: warning: variable ‘val’ set but not used [-Wunused-but-set-variable] I couldn't see a way good way of programming around this (perhaps in the second case, but it would get uselessly ugly), so perhaps just marking the variables as potentially unused would be appropriate? See patch. diff --git i/src/backend/nodes/read.c w/src/backend/nodes/read.c index 78775e8..5c872e8 100644 --- i/src/backend/nodes/read.c +++ w/src/backend/nodes/read.c @@ -219,7 +219,7 @@ nodeTokenType(char *token, int length) * We know the token will end at a character that strtol will stop at, * so we do not need to modify the string. */ - long val; + long val __attribute__((unused)); char *endptr; errno = 0; diff --git i/src/backend/nodes/readfuncs.c w/src/backend/nodes/readfuncs.c index 2288514..4c9e98f 100644 --- i/src/backend/nodes/readfuncs.c +++ w/src/backend/nodes/readfuncs.c @@ -47,7 +47,7 @@ /* And a few guys need only the pg_strtok support fields */ #define READ_TEMP_LOCALS() \ - char *token; \ + char *token __attribute__((unused)); \ int length /* ... but most need both */ -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] gcc 4.6 -Wunused-but-set-variable
Peter Eisentraut pete...@gmx.net writes: I couldn't see a way good way of programming around this (perhaps in the second case, but it would get uselessly ugly), so perhaps just marking the variables as potentially unused would be appropriate? See patch. Of course this would break not only on non-gcc compilers, but old versions of gcc. I'd suggest a macro (cf PERL_UNUSED_DECL) and some version checks at the site of the macro declaration (perhaps the ones emitted by bison for its use of this construct will do). regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers