develooper Front page | perl.perl5.porters | Postings from June 2014

gcc -pedantic

Jarkko Hietaniemi
June 22, 2014 12:43
gcc -pedantic
Message ID:
As of f049db42ef969d7e9f6b8a1414143e9e0dfdbd62 one can 
-Accflags=-pedantic (or even -pedantic-errors), or use the 
long-forgotten Configure flag -Dgccansipedantic, and the core should
compile clean with that, modulo one upstream-reported grunt [1] about
unused my_perl.

Background: -std=c89 which we have had for years, is a bit pointless 
without -pedantic... lone -std=c89 means "if there are multiple possible 
ways to interpret the code, go the C89 way".  Only with -pedantic it 
means "there is only way".

Enabling -pedantic* by default while tempting to stay "C89-clean"
is a bit problematic, at least for these reasons:
- C99 variadic macros are lost
- gcc grace groups are lost (not so great a loss if they are only for
   grouping since Ye Olde "do { ... } while (0)" works, harder to replace
   if the last-value-returning is used)
- the dtrace code is generated code which includes both gcc brace groups
   *and* dollars in identifiers (yes, that's a commonly allowed; and of
   course VMS would feel naked without them)
So this change doesn't enable -pedantic* by default.

An additional fun fact found: with -pedantic and -DDEBUGGING some
generated string literals can get so monstrously long (longer than 509 
bytes!) that the -Wno-overlength-strings is added _not_ to whine about
such huge strings.  (Apparently that is the ANSI minimum length.)

These changes only affect the core compilation, the extra warning flags
are not propagated down to the extension code builds.  That would be a 
quite different fight.  (Note that running cflags.SH is now a bit
chattier than it used to.)

Even before this change, I had made so that (I think) the most common 
C89-violation was an error: -Werror=declaration-after-statement.  Now, 
if one enables -pedantic*, the -We=d-a-s is removed as redundant.  But,
if one doesn't, the -We=d-a-s is added.

If this change seems happy in Jenkins and in smokes, I would suggest 
adding -Accflags='-pedantic' to some smoke configs.  Maybe even
-pedantic-errors if feeling draconian.

[1] vutil.c, from the version distribution.  Reported upstream. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About