develooper Front page | perl.perl5.porters | Postings from March 2013

Re: [perl #117305] ISO C forbids braced-groups within expressions (cv.h, inline.h in 5.17.9)

Thread Previous | Thread Next
From:
Mark Martinec
Date:
March 23, 2013 23:28
Subject:
Re: [perl #117305] ISO C forbids braced-groups within expressions (cv.h, inline.h in 5.17.9)
Message ID:
201303230158.30702.Mark.Martinec@ijs.si
> But these definitions are conditional:
>     #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
>     #  define MUTABLE_PTR(p) ({ void *_p = (p); _p; })
[...]

> I'm not sure I understand this. Is the author suggesting that bleadperl
> built with -pedantic-errors doesn't set PERL_GCC_PEDANTIC?

Apparently yes.
I admit I do not fully understand the chain of includes and their macros.

> Because:
> $ sh Configure -des -Dusedevel -Accflags="-pedantic-errors"
> $ make
> `sh  cflags "optimize='-O2'" perlmini.o`  -DPERL_IS_MINIPERL
> -DPERL_EXTERNAL_GLOB perlmini.c CCCMD =  cc -DPERL_CORE -c
> -pedantic-errors -fno-strict-aliasing -pipe -fstack-protector
> -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -O2 
> -Wall -DPERL_GCC_PEDANTIC
> (note the -DPERL_GCC_PEDANTIC on the command-line)

My perl is not built with -pedantic-errors,
it's only some tool from that module (which includes EXTERN.h and perl.h)
that is built with -std=c99 -pedantic-errors.

> Or, is the author's module being built on a non-pedantic perl, but it adds
> -pedantic-errors to the command line when building the module's source
> files?

Yes, I believe so.

> In which case, I don't think perl has ever added PERL_GCC_PEDANTIC
> to the command line or any include file.

So here is the rub it seems.

> Do you have a definite pass / transition, i.e. this module builds under
> 5.X, but doesn't build under 5.Y?

That module builds fine with perl-5.16.2, so I made a quick
and dirty test, without fully understanding what is going on
behind the scenes:

- unpacked the virgin tarballs of perl-5.16.2 and perl-5.17.9
  each in its own directory

- copied a file config.h from my system's perl-5.16.2 which happens
  to be installed on that host into each of ./perl-5.16.2 and
  ./perl-5.17.9

- created a tiny program 0.c, all it does is includes the EXTERN.h and perl.h:
    #include "EXTERN.h"
    #include "perl.h"
    int main(int argc, char **argv) {}

So here is what happens:

  $ cd ~/perl-5.16.2/
  $ cc -I. -std=c99 -pedantic ~/0.c
perfect, no problems there.

Not so in 5.17.9:
  $ cd ~/perl-5.17.9
  $ cc -I. -std=c99 -pedantic ~/0.c
In file included from ./perl.h:3473,
                 from /home/mark/0.c:2:
./cv.h: In function 'S_CvGV':
./cv.h:194: warning: ISO C forbids braced-groups within expressions
./cv.h:196: warning: ISO C forbids braced-groups within expressions
./cv.h: In function 'CvNAME_HEK':
./cv.h:201: warning: ISO C forbids braced-groups within expressions
./cv.h:202: warning: ISO C forbids braced-groups within expressions
In file included from ./perl.h:5237,
                 from /home/mark/0.c:2:
./inline.h: In function 'S_av_top_index':
./inline.h:23: warning: ISO C forbids braced-groups within expressions


So it seems to me that your statement:
  | In which case, I don't think perl has ever added PERL_GCC_PEDANTIC
  | to the command line or any include file.
is the key here, but it just so happens that one can get away
despite this with 5.16.* .


  Mark


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About