Discussion:
M4 tests fail when built with PGI compilers
(too old to reply)
Eric Blake
2017-01-30 22:39:43 UTC
Permalink
Raw Message
[adding gnulib]

On 01/30/2017 03:48 PM, Stewart, Adam James wrote:
> I'm trying to build and install M4 1.4.18 with PGI 16.5, but `make check` crashes for me. I'm seeing thousands of lines that look like:
>
> PGC-W-0116-Constant value out of range for signed short or char (/blues/gpfs/home/software/spack-0.10.0/var/spack/stage/m4-1.4.18-zwtcbe4z66lx36aq7iuwsqbmz35a76jp/m4-1.4.18/tests/test-intprops.c: 164)
> PGC-W-0155-64-bit integral value truncated (/blues/gpfs/home/software/spack-0.10.0/var/spack/stage/m4-1.4.18-zwtcbe4z66lx36aq7iuwsqbmz35a76jp/m4-1.4.18/tests/test-intprops.c: 164)
> PGC-W-0155-Integer overflow in divide (/blues/gpfs/home/software/spack-0.10.0/var/spack/stage/m4-1.4.18-zwtcbe4z66lx36aq7iuwsqbmz35a76jp/m4-1.4.18/tests/test-intprops.c: 292)
> PGC-W-0086-Division by zero (/blues/gpfs/home/software/spack-0.10.0/var/spack/stage/m4-1.4.18-zwtcbe4z66lx36aq7iuwsqbmz35a76jp/m4-1.4.18/tests/test-intprops.c: 337)

Thanks for the report. The test-intprops.c file comes from gnulib, so
fixing it there will fix it for other packages that also inherit the
same test.

For our reference, can you please paste the actual source lines that the
compiler is complaining about? Even better would be computing the
preprocessed (but uncompiled) output, and showing the corresponding
lines after macro expansion. That may help us figure out whether the
bug is in the PGI compiler rather than our testsuite, and maybe even
give us some ideas of ways to work around the problem (whether it be
avoiding the compiler bug or fixing our code portability).

>
> I don't think test-intprops.c is compatible with the PGI compilers.

Is there an easy way to access a machine with a PGI compiler, so that
you don't have to do all the debugging yourself?

--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Paul Eggert
2017-01-31 02:44:15 UTC
Permalink
Raw Message
On 01/30/2017 02:39 PM, Eric Blake wrote:
>
>> I don't think test-intprops.c is compatible with the PGI compilers.

Yes, test-intprops.c runs afoul of a problem in the PGI compiler. I can
reproduce the problem in PGI 16.10 x86-64 by compiling this one-line
program:

short bar = -32768 <= 100000 && 100000 <= 32767 ? (short) 100000 : 0;

Although this is valid C code and is well-defined to initialize 'bar' to
0 on x86-64, pgcc warns "Constant value out of range for signed short or
char". Since the expression "(short) 100000" is not evaluated, the
warning is bogus. Although PGI generates thousands of similar warnings
for test-intprops.c, I expect that they are all bogus and that you can
ignore them. As 'make check' does not fail and I don't see an easy way
to suppress the bogus warnings, I suspect we ought to leave the code alone.

Admittedly these warnings are annoying. Adam, since you're a PGI user,
perhaps you could report the compiler bug or bugs to the PGI maintainers.

While I was at it, I looked at the other warnings that PGI generates for
GNU M4, and managed to silence most of the rest with this Gnulib patch:

http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=16f6a8d8d81cc93745a24c0fb89caab2c383ae3c

A half-dozen or so of the thousands of Gnulib warnings were actual
portability bugs in Gnulib, which made the exercise worth doing I
suppose. I don't think these bugs affect GNU M4.
Stewart, Adam James
2017-01-31 15:46:29 UTC
Permalink
Raw Message
Thanks Paul,

Yes, the warnings are annoying, but more importantly, `make check` doesn't pass for me. In fact, I'm not sure if it even gets to the testing phase. I think it crashes when trying to build the test suite.

I am also passing "--enable-c++" and "--with-libsigsegv=/path/to/libsigsegv" to configure, if that makes a difference. I'm also building it in a different directory than the one containing the configure script. I have attached my build output to help you debug the problem.

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

________________________________________
From: Paul Eggert [***@cs.ucla.edu]
Sent: Monday, January 30, 2017 8:44 PM
To: Stewart, Adam James
Cc: Eric Blake; bug-***@gnu.org; Bug-gnulib
Subject: Re: M4 tests fail when built with PGI compilers

On 01/30/2017 02:39 PM, Eric Blake wrote:
>
>> I don't think test-intprops.c is compatible with the PGI compilers.

Yes, test-intprops.c runs afoul of a problem in the PGI compiler. I can
reproduce the problem in PGI 16.10 x86-64 by compiling this one-line
program:

short bar = -32768 <= 100000 && 100000 <= 32767 ? (short) 100000 : 0;

Although this is valid C code and is well-defined to initialize 'bar' to
0 on x86-64, pgcc warns "Constant value out of range for signed short or
char". Since the expression "(short) 100000" is not evaluated, the
warning is bogus. Although PGI generates thousands of similar warnings
for test-intprops.c, I expect that they are all bogus and that you can
ignore them. As 'make check' does not fail and I don't see an easy way
to suppress the bogus warnings, I suspect we ought to leave the code alone.

Admittedly these warnings are annoying. Adam, since you're a PGI user,
perhaps you could report the compiler bug or bugs to the PGI maintainers.

While I was at it, I looked at the other warnings that PGI generates for
GNU M4, and managed to silence most of the rest with this Gnulib patch:

http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=16f6a8d8d81cc93745a24c0fb89caab2c383ae3c

A half-dozen or so of the thousands of Gnulib warnings were actual
portability bugs in Gnulib, which made the exercise worth doing I
suppose. I don't think these bugs affect GNU M4.
Paul Eggert
2017-01-31 22:49:37 UTC
Permalink
Raw Message
On 01/31/2017 07:46 AM, Stewart, Adam James wrote:
> Yes, the warnings are annoying, but more importantly, `make check` doesn't pass for me. In fact, I'm not sure if it even gets to the testing phase. I think it crashes when trying to build the test suite.

Your log file says all the M4 tests passed; see the line "All checks
successful". The tests that failed are all Gnulib tests that do not
suggest any problems in M4 proper, only problems in the Gnulib test
harness (plus one portability bug in Gnulib that M4 should not trigger).
So you should be OK.

The Gnulib 'make check' failures are fixed by the patch I mentioned
earlier, which should appear in the next version of GNU M4. Here it is
again:

http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=16f6a8d8d81cc93745a24c0fb89caab2c383ae3c
Stewart, Adam James
2017-02-06 21:37:51 UTC
Permalink
Raw Message
Thanks Paul,

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?

P.S. I submitted a ticket to PGI regarding the bogus warning messages you mentioned: http://www.pgroup.com/userforum/viewtopic.php?p=21440#21440

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

________________________________________
From: Paul Eggert [***@cs.ucla.edu]
Sent: Tuesday, January 31, 2017 4:49 PM
To: Stewart, Adam James
Cc: Eric Blake; bug-***@gnu.org; Bug-gnulib
Subject: Re: M4 tests fail when built with PGI compilers

On 01/31/2017 07:46 AM, Stewart, Adam James wrote:
> Yes, the warnings are annoying, but more importantly, `make check` doesn't pass for me. In fact, I'm not sure if it even gets to the testing phase. I think it crashes when trying to build the test suite.

Your log file says all the M4 tests passed; see the line "All checks
successful". The tests that failed are all Gnulib tests that do not
suggest any problems in M4 proper, only problems in the Gnulib test
harness (plus one portability bug in Gnulib that M4 should not trigger).
So you should be OK.

The Gnulib 'make check' failures are fixed by the patch I mentioned
earlier, which should appear in the next version of GNU M4. Here it is
again:

http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=16f6a8d8d81cc93745a24c0fb89caab2c383ae3c
Paul Eggert
2017-02-09 00:19:21 UTC
Permalink
Raw Message
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.
Stewart, Adam James
2017-02-09 16:50:47 UTC
Permalink
Raw Message
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 [***@cs.ucla.edu]
Sent: Wednesday, February 08, 2017 6:19 PM
To: Stewart, Adam James
Cc: Eric Blake; bug-***@gnu.org; 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.
Bruno Haible
2017-02-12 11:57:18 UTC
Permalink
Raw Message
Paul Eggert wrote in
https://lists.gnu.org/archive/html/bug-gnulib/2017-01/msg00145.html:
>
> short bar = -32768 <= 100000 && 100000 <= 32767 ? (short) 100000 : 0;
>
> Although this is valid C code and is well-defined to initialize 'bar' to
> 0 on x86-64, pgcc warns "Constant value out of range for signed short or
> char". Since the expression "(short) 100000" is not evaluated, the
> warning is bogus. ...
>
> Admittedly these warnings are annoying. Adam, since you're a PGI user,
> perhaps you could report the compiler bug or bugs to the PGI maintainers.

GCC also emits warnings for dead code. Like here (seen in test-strtol.c):

=========================== foo.c ===========================
#include <errno.h>
#include <stdlib.h>

int
main ()
{
if (sizeof (long) > sizeof (int))
{
const char input[] = "4294967295";
char *ptr;
long result;
errno = 0;
result = strtol (input, &ptr, 10);
if (!(result == 65535L * 65537L)) abort ();
if (!(ptr == input + 10)) abort ();
if (!(errno == 0)) abort ();
}

return 0;
}
=============================================================

$ gcc -m32 -O -Wall foo.c
foo.c: In function ‘main’:
foo.c:14:30: warning: integer overflow in expression [-Woverflow]
if (!(result == 65535L * 65537L)) abort ();
^
$ gcc -v
...
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)

Should we report it as a GCC bug?

Bruno
Paul Eggert
2017-02-12 19:35:27 UTC
Permalink
Raw Message
Bruno Haible wrote:
> Should we report it as a GCC bug?

I think so. I created a bug report, here:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79479
Loading...