Discussion:
gnulib intprops.h build error with gcc 7
Adrian Bunk
2017-08-17 16:28:58 UTC
Permalink
Package: src:rush
Version: 1.8+dfsg-1
...
In file included from inttostr.h:25:0,
from anytostr.c:31,
intprops.h:236:34: error: expected ')' before '(' token
__builtin_add_overflow (a, b, (__typeof__ ((a) + (b)) *) 0)
^
Makefile:1284: recipe for target 'imaxtostr.o' failed
...
This can be reproduced with

$ cat test.c
# define _GL_ADD_OVERFLOW(a, b, min, max)
__builtin_add_overflow (a, b, (__typeof__ ((a) + (b)) *) 0)
$ gcc -c test.c
test.c:2:34: error: expected ‘)’ before ‘(’ token
__builtin_add_overflow (a, b, (__typeof__ ((a) + (b)) *) 0)
^
$


This is a problem in gnulib, introduced by

commit d22721e2efd88f26588c9710000eb1eeb3ec40de
Author: Paul Eggert <***@cs.ucla.edu>
Date: Mon Aug 29 10:08:32 2016 -0700

intprops.h: use __typeof__ with GCC 7

* lib/intprops.h (_GL_ADD_OVERFLOW, _GL_SUBTRACT_OVERFLOW)
(_GL_MULTIPLY_OVERFLOW): Use __typeof__ as in the GCC manual.
This avoids computing the expression's value (which might overflow!).


cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
Bruno Haible
2017-08-17 17:02:47 UTC
Permalink
Hi Adrian,

Could you please give the complete output of "gcc --version"?

Given that [1] references an URL that contains the string
'gcc7-20170126' whereas gcc 7 was released on 2017-05-02 [2],
it could be that the report is about a gcc prerelease that
came 3 months before the gcc 7 release.

Bruno

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=853649
[2] https://gcc.gnu.org/
Adrian Bunk
2017-08-17 17:10:13 UTC
Permalink
Post by Bruno Haible
Hi Adrian,
Could you please give the complete output of "gcc --version"?
Given that [1] references an URL that contains the string
'gcc7-20170126' whereas gcc 7 was released on 2017-05-02 [2],
it could be that the report is about a gcc prerelease that
came 3 months before the gcc 7 release.
For reproducing and my tiny testcase I was using
gcc (Debian 7.1.0-13) 7.1.0
from Debian unstable - that is GCC 7.2 release candidate 2
with minimal Debian patching.
Post by Bruno Haible
Bruno
...
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
Bruno Haible
2017-08-17 18:40:28 UTC
Permalink
Post by Adrian Bunk
For reproducing and my tiny testcase I was using
gcc (Debian 7.1.0-13) 7.1.0
from Debian unstable - that is GCC 7.2 release candidate 2
with minimal Debian patching.
OK thanks.

Now about your test case: It is not valid C to try to compile just an
expression.
================
a + b
================
is not a valid C compilation unit either. Can you submit a small test case
that
1) makes use of the intprops.h file from gnulib as a whole,
2) compiles with gcc 6 or earlier?

Bruno
Adrian Bunk
2017-08-17 19:24:28 UTC
Permalink
Post by Bruno Haible
...
Now about your test case: It is not valid C to try to compile just an
expression.
...
I was about to say that this was directly copied from intprops.h

And when double-checking that, I finally realized that this is
what is in intprops.h in rush - but intprops.h in current gnulib
git is fine.

When looking at them I missed that they are different at this relevant
macro, and that the problem is only in the older intprops.h shipped in
rush.

Sorry for the confusion
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
Loading...