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

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

Thread Previous
From:
Mark Martinec
Date:
March 22, 2013 19:30
Subject:
[perl #117305] ISO C forbids braced-groups within expressions (cv.h, inline.h in 5.17.9)
Message ID:
rt-3.6.HEAD-28177-1363980623-963.117305-75-0@perl.org
# New Ticket Created by  Mark Martinec 
# Please include the string:  [perl #117305]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=117305 >


This is a bug report for perl from Mark.Martinec@ijs.si,
generated with the help of perlbug 1.39 running under perl 5.17.9.


-----------------------------------------------------------------
[Please describe your issue here]

Perl include files (cv.h, inline.h, possibly others) use certain
macros as expressions (like CvNAMED, MUTABLE_PTR), but these macros
expand to "braced-group", which is not allowed in an expression
according to ISO C - but is mercifully allowed by gcc.

Some Perl modules use cc options -std=c99 -pedantic-errors
and include these perl .h files, so their compilation fails
with compile time errors like:

.../5.17.9/mach/CORE/cv.h:194: error: ISO C forbids braced-groups within expressions
.../5.17.9/mach/CORE/cv.h:196: error: ISO C forbids braced-groups within expressions
.../5.17.9/mach/CORE/cv.h:201: error: ISO C forbids braced-groups within expressions
.../5.17.9/mach/CORE/cv.h:202: error: ISO C forbids braced-groups within expressions
.../5.17.9/mach/CORE/inline.h:23: error: ISO C forbids braced-groups within expressions

Here is a source code example from cv.h near line 194:

PERL_STATIC_INLINE GV *
S_CvGV(CV *sv)
{
    return CvNAMED(sv)
	? 0
	: ((XPVCV*)MUTABLE_PTR(SvANY(sv)))->xcv_gv_u.xcv_gv;
}

which gets expanded by a C preprocessor into:

S_CvGV(CV *sv)
{
  return (((XPVCV*)({ void *_p = ((sv)->sv_any); _p; }))->xcv_flags & 0x8000)
    ? 0
    : ((XPVCV*)({ void *_p = ((sv)->sv_any); _p; }))->xcv_gv_u.xcv_gv;
}

which illustrates where "braced-group within expression"
comes into play.


An example of such CPAN module is ZMQ::LibZMQ3.  I have opened
a ticket with this module ([rt.cpan.org #84124] suggesting to
drop the -pedantic-errors option) - here is the author's reply:

  ( https://rt.cpan.org/Ticket/Display.html?id=84124 )

  Given some discussion on #p5p, I suspect that there is something wrong
  in the bleadperl isn't setting PERL_GCC_PEDANTIC. You might want to file
  this bug via perlbug. If they decide to release perl-5.18 without fixing
  this, I'll release a new version with manual PERL_GCC_PEDANTIC define.


So I suggest such constructs are either avoided, or clearly documented
that these include files do not comply with ISO C99 standard.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=library
    severity=medium
---
Site configuration information for perl 5.17.9:

Configured by mark at Fri Mar  1 15:29:16 CET 2013.

Summary of my perl5 (revision 5 version 17 subversion 9) configuration:
   
  Platform:
    osname=freebsd, osvers=7.2-release-p2, archname=amd64-freebsd
    uname='freebsd dorothy.ijs.si 7.2-release-p2 freebsd 7.2-release-p2 #0: wed jul 15 15:45:26 cest 2009 lesi@dorothy.ijs.si:usrobjusrsrcsysdorothy amd64 '
    config_args='-Dusedevel -sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.17.9/mach -Dprivlib=/usr/local/lib/perl5/5.17.9 -Dman3dir=/usr/local/lib/perl5/5.17.9/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.17.9/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.17.9 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.17.9/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dinc_version_list=none -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.17.9/BSDPAN" -Doptimize=-O2 -fno-strict-aliasing -pipe -Ui_gdbm -Dusethreads=n -Dusemymalloc=n -Duse64bitint'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.17.9/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
    optimize='-O2 -fno-strict-aliasing -pipe',
    cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.17.9/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.2.1 20070719  [FreeBSD]', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-pthread -Wl,-E  -fstack-protector -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lgdbm -lm -lcrypt -lutil
    perllibs=-lm -lcrypt -lutil
    libc=, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -Wl,-R/usr/local/lib/perl5/5.17.9/mach/CORE'
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib -fstack-protector'

Locally applied patches:
    

---
@INC for perl 5.17.9:
    /usr/local/lib/perl5/5.17.9/BSDPAN
    /usr/local/lib/perl5/site_perl/5.17.9/mach
    /usr/local/lib/perl5/site_perl/5.17.9
    /usr/local/lib/perl5/5.17.9/mach
    /usr/local/lib/perl5/5.17.9
    .

---
Environment for perl 5.17.9:
    HOME=/root
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash


Thread Previous


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