./configure fails when compiler defaults to C23 standard
user202729 at protonmail.com
user202729 at protonmail.com
Sun Dec 28 09:55:23 CET 2025
I'm trying to compile GMP 6.3.0 from source on Arch Linux, which uses GCC 15.1.1.
When running `./configure` (with no argument), I get
```
[]$ ./configure
checking build system type... broadwell-pc-linux-gnu
checking host system type... broadwell-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking ABI=64
checking compiler gcc -O2 -pedantic -fomit-frame-pointer -m64 ... no, long long reliability test 1
checking whether cc is gcc... yes
checking compiler cc -O2 -pedantic -fomit-frame-pointer -m64 ... no, long long reliability test 1
checking ABI=x32
checking compiler gcc -O2 -pedantic -fomit-frame-pointer -mx32 ... no
checking whether cc is gcc... yes
checking compiler cc -O2 -pedantic -fomit-frame-pointer -mx32 ... no
checking ABI=32
checking compiler gcc -m32 -O2 -pedantic -fomit-frame-pointer ... no, long long reliability test 1
checking compiler gcc -O2 -pedantic -fomit-frame-pointer ... no, long long reliability test 1
checking compiler icc -no-gcc ... no
checking whether cc is gcc... yes
checking compiler cc -m32 -O2 -pedantic -fomit-frame-pointer ... no, long long reliability test 1
checking compiler cc -O2 -pedantic -fomit-frame-pointer ... no, long long reliability test 1
configure: error: could not find a working compiler, see config.log for details
```
The problem is the following check
```
GMP_PROG_CC_WORKS_PART([$1], [long long reliability test 1],
[/* The following provokes a segfault in the compiler on powerpc-apple-darwin.
Extracted from tests/mpn/t-iord_u.c. Causes Apple's gcc 3.3 build 1640 and
1666 to segfault with e.g., -O2 -mpowerpc64. */
#if defined (__GNUC__) && ! defined (__cplusplus)
typedef unsigned long long t1;typedef t1*t2;
void g(){}
void h(){}
static __inline__ t1 e(t2 rp,t2 up,int n,t1 v0)
{t1 c,x,r;int i;if(v0){c=1;for(i=1;i<n;i++){x=up[i];r=x+1;rp[i]=r;}}return c;}
void f(){static const struct{t1 n;t1 src[9];t1 want[9];}d[]={{1,{0},{1}},};t1 got[9];int i;
for(i=0;i<1;i++){if(e(got,got,9,d[i].n)==0)h();g(i,d[i].src,d[i].n,got,d[i].want,9);if(d[i].n)h();}}
#else
int dummy;
#endif
])
```
Because GCC 15.1.1 defaults to C23, and in C23, `void g(){}` is equivalent to `void g(void){}`, the call `g(i,d[i].src,d[i].n,got,d[i].want,9)` is invalid.
I can see two ways to fix it:
1. Change `void g(){}` to `void g(...){}`. I apply this patch on my machine and it compiles successfully.
2. add a check `__STDC_VERSION__ < 202311L`.
Sent with Proton Mail secure email.
More information about the gmp-bugs
mailing list