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

Re: -std=c89

Thread Previous
From:
Leon Timmermans
Date:
January 6, 2014 00:01
Subject:
Re: -std=c89
Message ID:
CAHhgV8ha0-S8TWn6D0bOV+Y-A__Tz5HRdKZCHMe2Pu9OxTZiFQ@mail.gmail.com
On Sun, Jan 5, 2014 at 5:09 AM, George Greer <perl@greerga.m-l.org> wrote:

> With the persistent problem of gcc/clang being too loose about
> declarations after statements (and only caught regularly by the Windows
> smoker) I thought I'd add '-std=c89' to the command-line options of my
> clang smoker (since it makes no sense under g++).
>
> First problem is that neither clang nor gcc that I have will error on
> declarations after statements with '-std=c89'. (See previous email.) That
> can be worked around with '-Werror=declaration-after-statement', at least.
>

I think -pedantic is the option that you want.


> Second problem is that I get a build error:
> - - - 8< - - - 8< - - -
> In file included from perl.c:33:
> ./perl.h:750:14: error: conflicting types for 'syscall'
> EXTERN_C int syscall(int, ...);
>              ^
> /usr/include/unistd.h:1080:17: note: previous declaration is here
> extern long int syscall (long int __sysno, ...) __THROW;
>                 ^
> 1 error generated.
> make: *** [perlmini.o] Error 1
> - - - 8< - - - 8< - - -
>

This seems to be a bug in the HAS_SYSCALLPROTO logic. It should detect that
it's already declared and not try to use the backup declaration. It's
probably explain by the Configure breakage you describe.


> According to the 'man' pages, the perl.h prototype is correct. (Ubuntu
> libc6-dev version 2.17-0ubuntu5.1)
>
> Probably also problematic, there are Configure differences.  The two lines
> were:
>
> git clean -dxqf && ./Configure -des -Dusedevel -Dcc=clang
> -Accflags="-DPERL_POISON -std=c89 -Werror=declaration-after-statement
> -fsanitize=address" -Aldflags="-fsanitize=address"
> vs.
> git clean -dxqf && ./Configure -des -Dusedevel -Dcc=clang
> -Accflags="-DPERL_POISON -Werror=declaration-after-statement
> -fsanitize=address" -Aldflags="-fsanitize=address"
>
> (+ lines have -std=c89)
>
> - - - 8< - - - 8< - - -
> -<sys/file.h> defines the *_OK access constants.
> +<unistd.h> defines the *_OK access constants.
> ...
>  Checking to see if your libm supports _LIB_VERSION...
> -Yes, it does (2)
> +No, it does not (probably harmless)
> ...
>  sigaction() found.
> +try.c:10:22: error: variable has incomplete type 'struct sigaction'
> +    struct sigaction act, oact;
> +                     ^
> +try.c:10:12: note: forward declaration of 'struct sigaction'
> +    struct sigaction act, oact;
> +           ^
> +try.c:10:27: error: variable has incomplete type 'struct sigaction'
> +    struct sigaction act, oact;
> +                          ^
> +try.c:10:12: note: forward declaration of 'struct sigaction'
> +    struct sigaction act, oact;
> +           ^
> +2 errors generated.
> +But you don't seem to have a usable struct sigaction.
>  <sunmath.h> NOT found.
> -Checking to see if you have signbit() available to work on double... Yes.
> +Checking to see if you have signbit() available to work on double... Nope.
> ...
> -POSIX sigsetjmp found.
> +sigsetjmp not found.
> ...
>  Checking Berkeley DB version ...
> -Looks OK.
> -Checking return type needed for hash for Berkeley DB ...
> -Checking return type needed for prefix for Berkeley DB ...
> +In file included from try.c:11:
> +/usr/include/db.h:1013:2: error: unknown type name 'u_int'
> +        u_int port;
> +        ^
> +/usr/include/db.h:2196:2: error: unknown type name 'u_int'
> +        u_int           mp_ncache;      /* Initial number of cache
> regions */
> +        ^
> +/usr/include/db.h:2390:33: error: unknown type name 'u_int'
> +                __P((DB_ENV *, const char **, u_int *));
> +                                              ^
> +/usr/include/db.h:40:21: note: expanded from macro '__P'
> +#define __P(protos)     protos
> +                        ^
> +/usr/include/db.h:2395:18: error: unknown type name 'u_int'
> +                __P((DB_ENV *, u_int *, DB_REPMGR_SITE **));
> +                               ^
> +/usr/include/db.h:40:21: note: expanded from macro '__P'
> +#define __P(protos)     protos
> +                        ^
> +/usr/include/db.h:2819:48: error: redefinition of parameter 'u_long'
> +int db_env_set_func_yield __P((int (*)(u_long, u_long)));
> +                                               ^
> +/usr/include/db.h:40:21: note: expanded from macro '__P'
> +#define __P(protos)     protos
> +                        ^
> +/usr/include/db.h:2819:40: error: a parameter list without types is only
> allowed in a function definition
> +int db_env_set_func_yield __P((int (*)(u_long, u_long)));
> +                                       ^
> +/usr/include/db.h:40:21: note: expanded from macro '__P'
> +#define __P(protos)     protos
> +                        ^
> +6 errors generated.
> +I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB.
> +Removing unusable -ldb from library list
> +libs = -lnsl -lgdbm -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
>  Using our internal random number implementation...
> - - - 8< - - - 8< - - -
>
> (without perl poison and address sanitizer doesn't change result)
>
> As such it may not be immediately feasible to use '-std=c89' anyway.
>
> So for now only errors on declarations after statements on my clang
> smokers.


That does look like a bug too :-(

Leon

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