develooper Front page | perl.perl5.porters | Postings from September 2006

[perl #40409] __attribute__format___printf__ implies nonull on *BSD

Thread Previous
From:
pgollucci @ home . p6m7g8 . net
Date:
September 24, 2006 02:26
Subject:
[perl #40409] __attribute__format___printf__ implies nonull on *BSD
Message ID:
rt-3.5.HEAD-31263-1159063537-1519.40409-75-0@perl.org
# New Ticket Created by  pgollucci@home.p6m7g8.net 
# Please include the string:  [perl #40409]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=40409 >



This is a bug report for perl from pgollucci@home.p6m7g8.net,
generated with the help of perlbug 1.35 running under perl 5.9.4.


-----------------------------------------------------------------
[Please enter your report here]

Hi,

I can't for the life of me figure out how, or why gcc on FreeBSD decides that this implies nonnull(1), but it does.

The closest thing I can find is in:
/usr/src/contrib/gcc/ansidecl.h:
/* Use ATTRIBUTE_PRINTF when the format specifier must not be NULL.
   This was the case for the `printf' format attribute by itself
   before GCC 3.3, but as of 3.3 we need to add the `nonnull'
   attribute to retain this behavior.  */
#ifndef ATTRIBUTE_PRINTF
#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m)
#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
#define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
#endif /* ATTRIBUTE_PRINTF */

/* Use ATTRIBUTE_NULL_PRINTF when the format specifier may be NULL.  A
   NULL format specifier was allowed as of gcc 3.3.  */
#ifndef ATTRIBUTE_NULL_PRINTF
# if (GCC_VERSION >= 3003)
#  define ATTRIBUTE_NULL_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
# else
#  define ATTRIBUTE_NULL_PRINTF(m, n)
# endif /* GNUC >= 3.3 */
# define ATTRIBUTE_NULL_PRINTF_1 ATTRIBUTE_NULL_PRINTF(1, 2)
# define ATTRIBUTE_NULL_PRINTF_2 ATTRIBUTE_NULL_PRINTF(2, 3)
# define ATTRIBUTE_NULL_PRINTF_3 ATTRIBUTE_NULL_PRINTF(3, 4)
# define ATTRIBUTE_NULL_PRINTF_4 ATTRIBUTE_NULL_PRINTF(4, 5)
# define ATTRIBUTE_NULL_PRINTF_5 ATTRIBUTE_NULL_PRINTF(5, 6)
#endif /* ATTRIBUTE_NULL_PRINTF */

Yes, I've been debugging this for like 8 months now....

AFAIK, the below declarations in proto.h are correct, and work fine on every other platform I can access.

Now this is nothing more then a mere nuisance, UNTIL, you get third party software that adds -Werror to your CFLAGS and
BOOOOM your compile breaks.  At the least, this breaks mod_perl2 ( perl Makefile.PL MP_MAINTAINER=1)
To answer someones previous question from a few months ago, yes, removing the __attribute__ line cures the problem.

Somehow, we need to code around this _BEFORE_ 5.10 is released.
I've tried ALL gcc versions in the ports tree -- it affects all of them.

If I had to guess, I'd bet NetBSD,OpenBSD.
I've no doubt DragonFlyDSD as well

gcc28
gcc295
gcc30
gcc32
gcc33
gcc34
gcc40 20060914
gcc41 20060915
gcc42 20060916

pgollucci@pgollucci.office.tmcs /home/pgollucci/dev/src/perl-bleed 350 0>gcc -Wall -c croak.c -o croak
croak.c: In function `main':
croak.c:8: warning: null format string
croak.c:9: warning: null format string

pgollucci@pgollucci.office.tmcs /home/pgollucci/dev/src/perl-bleed 351 0>cat croak.c
#include <stdlib.h>

#include "EXTERN.h"
#include "perl.h"

int main(void) {

  Perl_croak(aTHX_ NULL);
  Perl_die(aTHX_ NULL);

  return EXIT_SUCCESS;
}

proto.h [snipped]
PERL_CALLCONV OP*       Perl_die(pTHX_ const char* pat, ...)
                        __attribute__format__(__printf__,1,2);

PERL_CALLCONV void      Perl_croak(pTHX_ const char* pat, ...)
                        __attribute__noreturn__
                        __attribute__format__(__printf__,pTHX_1,pTHX_2);





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

Configured by pgollucci at Sat Sep 23 18:51:56 PDT 2006.

Summary of my perl5 (revision 5 version 9 subversion 4 patch 28881) configuration:
  Platform:
    osname=freebsd, osvers=6.1-stable, archname=i386-freebsd-64int
    uname='freebsd home.p6m7g8.net 6.1-stable freebsd 6.1-stable #0: mon jul 3 23:24:44 pdt 2006 pgollucci@home.p6m7g8.net:usrobjusrsrcsyshome i386 '
    config_args='-sde -Dprefix=/usr/local/software/freebsd-6.1-stable/3.4.4/perl/r28881 -Dman3dir=/usr/local/software/freebsd-6.1-stable/3.4.4/perl/r28881/man/man3 -Dman1dir=/usr/local/software/freebsd-6.1-stable/3.4.4/perl/r28881/man/man1 -Dsiteman3dir=/usr/local/software/freebsd-6.1-stable/3.4.4/perl/r28881/man/man3 -Dsiteman1die=/usr/local/software/freebsd-6.1-stable/3.4.4/perl/r28881/man/man1 -Dscriptdir=/usr/local/software/freebsd-6.1-stable/3.4.4/perl/r28881/bin -Uinstallusrbinperl -Dcc=gcc -Duseshrplib -Dusedevel -Dusethreads=n -Dusemymalloc=n -Duse64bitint -Doptimize=-g3 -O0 -DDEBUGGING -Dccflags=-pipe -Ud_dosuid -Ui_gdbm -Ubincompat5005'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-pipe -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DDEBUGGING -fno-strict-aliasing -I/usr/local/include',
    optimize='-g3 -O0 -DDEBUGGING',
    cppflags='-pipe -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='3.4.4 [FreeBSD] 20050518', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags ='-Wl,-E  -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lgdbm -lm -lcrypt -lutil -lc
    perllibs=-lm -lcrypt -lutil -lc
    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/software/freebsd-6.1-stable/3.4.4/perl/r28881/lib/5.9.4/i386-freebsd-64int/CORE'
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl 5.9.4:
    /usr/local/software/freebsd-6.1-stable/3.4.4/perl/r28881/lib/5.9.4/i386-freebsd-64int
    /usr/local/software/freebsd-6.1-stable/3.4.4/perl/r28881/lib/5.9.4
    /usr/local/software/freebsd-6.1-stable/3.4.4/perl/r28881/lib/site_perl/5.9.4/i386-freebsd-64int
    /usr/local/software/freebsd-6.1-stable/3.4.4/perl/r28881/lib/site_perl/5.9.4
    .

---
Environment for perl 5.9.4:
    HOME=/home/pgollucci
    LANG=
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/pgollucci/bin:/home/pgollucci/vms:/usr/local/gnu-autotools/bin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
    PERLDOC_PAGER=less -+C -E
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh


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