RE: M4 tests fail when built with PGI compilers

"Stewart, Adam James" <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs,gmane.comp.gnu.m4.bugs
Message-ID <[email protected]>
Paul,

I didn't realize my PGI installation was already obsolete. I updated to PGI 16.10, applied your patch, and `make check` passes all tests! Thanks for the help!

Adam J. Stewart
Assistant Systems Administrator
Laboratory Computing Resource Center
Computing, Environment and Life Sciences
Argonne National Laboratory

________________________________________
From: Paul Eggert [[email protected]]
Sent: Wednesday, February 08, 2017 6:19 PM
To: Stewart, Adam James
Cc: Eric Blake; [email protected]; Bug-gnulib
Subject: Re: M4 tests fail when built with PGI compilers

On 02/06/2017 01:37 PM, Stewart, Adam James wrote:
> I tried applying your patch, and it looks like I got a bit further along, but `make check` still crashes with:
>
>    CC       test-stddef.o
> PGC-S-0045-Illegal field size (/blues/gpfs/home/software/spack-0.10.0/var/spack/stage/m4-1.4.18-zwtcbe4z66lx36aq7iuwsqbmz35a76jp/m4-1.4.18/tests/test-stddef.c: 45)
> PGC-S-0045-Illegal field size (/blues/gpfs/home/software/spack-0.10.0/var/spack/stage/m4-1.4.18-zwtcbe4z66lx36aq7iuwsqbmz35a76jp/m4-1.4.18/tests/test-stddef.c: 46)
> PGC/x86-64 Linux 16.5-0: compilation completed with severe errors
> make[5]: *** [test-stddef.o] Error 2
>
> Lines 45 and 46 of test-stddef.c look like:
>
>        /* Solaris 10 has a bug where offsetof is under-parenthesized, and
>        cannot be used as an arbitrary expression.  However, since it is
>        unlikely to bite real code, we ignore that short-coming.  */
>         /* verify (sizeof offsetof (struct d, e) == sizeof (size_t)); */
> 45   verify (sizeof (offsetof (struct d, e)) == sizeof (size_t));
> 46   verify (offsetof (struct d, e) < -1); /* Must be unsigned.  */
>         verify (offsetof (struct d, f) == 1);
>
> Is this expected?

No, possibly it's a bug in pgcc, possibly it's a Gnulib bug, or maybe
it's just that Gnulib should work around the pgcc bug. It's hard to tell
from these symptoms. To figure it out, you might try doing this:

   cd tests && rm test-stddef.o && make V=1 test-stddef.o

This will output some long command like this:

source='../../m4-1.4.18/tests/test-stddef.c' object='test-stddef.o'
libtool=no \
DEPDIR=.deps depmode=pgcc /bin/sh ../../m4-1.4.18/build-aux/depcomp \
pgcc -DEXEEXT=\"\" -I. -I../../m4-1.4.18/tests -I../lib
-DIN_M4_GNULIB_TESTS=1 -I. -I../../m4-1.4.18/tests -I..
-I../../m4-1.4.18/tests/.. -I../lib -I../../m4-1.4.18/tests/../lib   -g
-c -o test-stddef.o ../../m4-1.4.18/tests/test-stddef.c

Change the "-g -c -o test-stddef.o" to "-E" and collect the output into
a file t.i, like this:

pgcc -DEXEEXT=\"\" -I. -I../../m4-1.4.18/tests -I../lib
-DIN_M4_GNULIB_TESTS=1 -I. -I../../m4-1.4.18/tests -I..
-I../../m4-1.4.18/tests/.. -I../lib -I../../m4-1.4.18/tests/../lib -E
../../m4-1.4.18/tests/test-stddef.c >t.i

Then look in t.i for the first line after the declaration of struct d.
On my platform the line looks like this:

extern int ( * _gl_verify_function45 ( void ) ) [ ( ! ! sizeof ( struct
{ unsigned int _gl_verify_error_if_negative : ( sizeof ( ( ( unsigned
long ) ( & ( ( ( struct d * ) 0 ) -> e ) ) ) ) == sizeof ( size_t ) ) ?
1 : - 1 ; } ) ) ] ;

If it looks different, figure out why. If not, try compiling this test
case with pgcc -c:

   #include <stddef.h>
   struct d { char e; char f; };

   extern int (*g (void))
   [(!!sizeof (struct { unsigned int h :
         (sizeof (offsetof (struct d, e)) == sizeof (size_t)) ? 1 : -1;
}))];

This is valid C code, and if pgcc rejects it you have a simple case
illustrating a pgcc compiler bug.

I notice you're running pgcc 16.5. For what it's worth I do not observe
the problem with pgcc 16.10 (x86-64 GNU/Linux). So maybe it's a pgcc bug
that is already fixed in later versions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.