Skip to content

d51aa1a build-time failure with clang++ and g++ #23725

@jkeenan

Description

@jkeenan

In this smoke-testing report filed by @cjg-cguevara, we observe a build-time (make) failure when compiling with clang++ version 19 on FreeBSD-14.3.

I have reproduced this failure on the FreeBSD machine from which I customarily generate smoke-test reports. I rarely smoke-test clang++, so the point when this build failure started to occur was not immediately evident to me.

On this machine, the default clang++ (/usr/bin/clang++) is version 18. Configuring and building as follows:

sh ./Configure -des -Dusedevel -Dusethreads -Dcc=clang++ && make test_prep 2>&1

... I got plenty of this kind of warning in both ./Configure and make test_prep ...

clang++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]

... but, then again, I've come to expect that with c++-equivalent compilers. What I did not expect was for the build to fail here:

clang++ -c -DPERL_CORE -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DNO_POSIX_2008_LOCALE -I/usr/local/include -O2 -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings pp.c
clang++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
pp.c:1343:18: error: use of undeclared identifier '_Bool'
 1343 |             if (!S_iv_mul_may_overflow(il, ir, &result)) {
      |                  ^
./inline.h:3540:51: note: expanded from macro 'S_iv_mul_may_overflow'
 3540 | #    define S_iv_mul_may_overflow(il, ir, result) ckd_mul(result, il, ir)
      |                                                   ^
/usr/include/stdckdint.h:32:3: note: expanded from macro 'ckd_mul'
   32 |         (_Bool)__builtin_mul_overflow((a), (b), (result))
      |          ^
pp.c:1409:18: error: use of undeclared identifier '_Bool'
 1409 |             if (!S_uv_mul_overflow(alow, blow, &product)) {
      |                  ^
./inline.h:3567:49: note: expanded from macro 'S_uv_mul_overflow'
 3567 | #    define S_uv_mul_overflow(auv, buv, result) ckd_mul(result, auv, buv)
      |                                                 ^
/usr/include/stdckdint.h:32:3: note: expanded from macro 'ckd_mul'
   32 |         (_Bool)__builtin_mul_overflow((a), (b), (result))
      |          ^
pp.c:1874:18: error: use of undeclared identifier '_Bool'
 1874 |             if (!S_iv_sub_may_overflow(il, ir, &result)) {
      |                  ^
./inline.h:3507:51: note: expanded from macro 'S_iv_sub_may_overflow'
 3507 | #    define S_iv_sub_may_overflow(il, ir, result) ckd_sub(result, il, ir)
      |                                                   ^
/usr/include/stdckdint.h:24:3: note: expanded from macro 'ckd_sub'
   24 |         (_Bool)__builtin_sub_overflow((a), (b), (result))
      |          ^
3 errors generated.
*** Error code 1

Stop.
make: stopped in /usr/home/jkeenan/gitwork/perl

I got the same build-time failure when using clang++19 on the same box. (I have not yet tried clang++20.)

I also got a build-time failure when targeting miniperl:

sh ./Configure -des -Dusedevel -Dusethreads -Dcc=clang++ && make miniperl
...
clang++ -c -DPERL_CORE -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DNO_POSIX_2008_LOCALE -I/usr/local/include -O2 -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings pp.c
clang++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
pp.c:1343:18: error: use of undeclared identifier '_Bool'
 1343 |             if (!S_iv_mul_may_overflow(il, ir, &result)) {
      |                  ^
./inline.h:3540:51: note: expanded from macro 'S_iv_mul_may_overflow'
 3540 | #    define S_iv_mul_may_overflow(il, ir, result) ckd_mul(result, il, ir)
      |                                                   ^
/usr/include/stdckdint.h:32:3: note: expanded from macro 'ckd_mul'
   32 |         (_Bool)__builtin_mul_overflow((a), (b), (result))
      |          ^
pp.c:1409:18: error: use of undeclared identifier '_Bool'
 1409 |             if (!S_uv_mul_overflow(alow, blow, &product)) {
      |                  ^
./inline.h:3567:49: note: expanded from macro 'S_uv_mul_overflow'
 3567 | #    define S_uv_mul_overflow(auv, buv, result) ckd_mul(result, auv, buv)
      |                                                 ^
/usr/include/stdckdint.h:32:3: note: expanded from macro 'ckd_mul'
   32 |         (_Bool)__builtin_mul_overflow((a), (b), (result))
      |          ^
pp.c:1874:18: error: use of undeclared identifier '_Bool'
 1874 |             if (!S_iv_sub_may_overflow(il, ir, &result)) {
      |                  ^
./inline.h:3507:51: note: expanded from macro 'S_iv_sub_may_overflow'
 3507 | #    define S_iv_sub_may_overflow(il, ir, result) ckd_sub(result, il, ir)
      |                                                   ^
/usr/include/stdckdint.h:24:3: note: expanded from macro 'ckd_sub'
   24 |         (_Bool)__builtin_sub_overflow((a), (b), (result))
      |          ^
3 errors generated.
*** Error code 1

Stop.

I next tried using g++. The latest version available on this machine was 14. Here I configured with:

$ sh ./Configure -des -Dusedevel -Dcc=g++14 && make miniperl

make miniperl died here:

g++14 -c -DPERL_CORE -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DNO_POSIX_2008_LOCALE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_FORTIFY_SOURCE=2 -O2 -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wwrite-strings pp.c
In file included from inline.h:3460,
                 from perl.h:8080,
                 from pp.c:28:
pp.c: In function 'OP* Perl_pp_multiply()':
inline.h:3540:51: error: '_Bool' was not declared in this scope
 3540 | #    define S_iv_mul_may_overflow(il, ir, result) ckd_mul(result, il, ir)
      |                                                   ^~~~~~~
pp.c:1343:18: note: in expansion of macro 'S_iv_mul_may_overflow'
 1343 |             if (!S_iv_mul_may_overflow(il, ir, &result)) {
      |                  ^~~~~~~~~~~~~~~~~~~~~
inline.h:3540:51: error: expected ')' before '__builtin_mul_overflow'
 3540 | #    define S_iv_mul_may_overflow(il, ir, result) ckd_mul(result, il, ir)
      |                                                   ^~~~~~~
pp.c:1343:18: note: in expansion of macro 'S_iv_mul_may_overflow'
 1343 |             if (!S_iv_mul_may_overflow(il, ir, &result)) {
      |                  ^~~~~~~~~~~~~~~~~~~~~
pp.c:1346:14: error: expected ')' before 'goto'
 1346 |             }
      |              ^
      |              )
 1347 |             goto generic;
      |             ~~~~
pp.c:1343:16: note: to match this '('
 1343 |             if (!S_iv_mul_may_overflow(il, ir, &result)) {
      |                ^
pp.c:1347:25: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
 1347 |             goto generic;
      |                         ^
pp.c:1339:16: warning: unused variable 'result' [-Wunused-variable]
 1339 |             IV result;
      |                ^~~~~~
inline.h:3567:49: error: '_Bool' was not declared in this scope
 3567 | #    define S_uv_mul_overflow(auv, buv, result) ckd_mul(result, auv, buv)
      |                                                 ^~~~~~~
pp.c:1409:18: note: in expansion of macro 'S_uv_mul_overflow'
 1409 |             if (!S_uv_mul_overflow(alow, blow, &product)) {
      |                  ^~~~~~~~~~~~~~~~~
inline.h:3567:49: error: expected ')' before '__builtin_mul_overflow'
 3567 | #    define S_uv_mul_overflow(auv, buv, result) ckd_mul(result, auv, buv)
      |                                                 ^~~~~~~
pp.c:1409:18: note: in expansion of macro 'S_uv_mul_overflow'
 1409 |             if (!S_uv_mul_overflow(alow, blow, &product)) {
      |                  ^~~~~~~~~~~~~~~~~
pp.c:1419:14: error: expected ')' before '}' token
 1419 |             } /* ahigh && bhigh */
      |              ^
      |              )
 1420 |         } /* SvIOK(svl) */
      |         ~     
pp.c:1409:16: note: to match this '('
 1409 |             if (!S_uv_mul_overflow(alow, blow, &product)) {
      |                ^
pp.c:1420:9: error: expected primary-expression before '}' token
 1420 |         } /* SvIOK(svl) */
      |         ^
pp.c:1382:16: warning: unused variable 'product' [-Wunused-variable]
 1382 |             UV product;
      |                ^~~~~~~
pp.c:1370:3: warning: label 'generic' defined but not used [-Wunused-label]
 1370 |   generic:
      |   ^~~~~~~
pp.c: In function 'OP* Perl_pp_subtract()':
inline.h:3507:51: error: '_Bool' was not declared in this scope
 3507 | #    define S_iv_sub_may_overflow(il, ir, result) ckd_sub(result, il, ir)
      |                                                   ^~~~~~~
pp.c:1874:18: note: in expansion of macro 'S_iv_sub_may_overflow'
 1874 |             if (!S_iv_sub_may_overflow(il, ir, &result)) {
      |                  ^~~~~~~~~~~~~~~~~~~~~
inline.h:3507:51: error: expected ')' before '__builtin_sub_overflow'
 3507 | #    define S_iv_sub_may_overflow(il, ir, result) ckd_sub(result, il, ir)
      |                                                   ^~~~~~~
pp.c:1874:18: note: in expansion of macro 'S_iv_sub_may_overflow'
 1874 |             if (!S_iv_sub_may_overflow(il, ir, &result)) {
      |                  ^~~~~~~~~~~~~~~~~~~~~
pp.c:1877:14: error: expected ')' before 'goto'
 1877 |             }
      |              ^
      |              )
 1878 |             goto generic;
      |             ~~~~
pp.c:1874:16: note: to match this '('
 1874 |             if (!S_iv_sub_may_overflow(il, ir, &result)) {
      |                ^
pp.c:1878:25: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
 1878 |             goto generic;
      |                         ^
pp.c:1870:16: warning: unused variable 'result' [-Wunused-variable]
 1870 |             IV result;
      |                ^~~~~~
pp.c:1894:3: warning: label 'generic' defined but not used [-Wunused-label]
 1894 |   generic:
      |   ^~~~~~~
*** Error code 1

Stop.

Finally, I bisected using the following invocation:

$ perl Porting/bisect.pl \
--test-build -Dcc=clang++ \
--start c4da28b08d \
--end e96b7226ea

Behavior changed at d51aa1a, committed to blead on Sept 16.

d51aa1a511cb145eb6487dbc3bef0397bd6ea156 is the first bad commit
commit d51aa1a511cb145eb6487dbc3bef0397bd6ea156
Author: TAKAI Kousuke <[email protected]>
Date:   Fri Aug 29 01:48:30 2025 +0900
Commit:     Karl Williamson <[email protected]>
CommitDate: Tue Sep 16 13:55:31 2025 -0600


    Introduce I_STDCKDINT config macro

    This macro is defined in config.h if <stdckdint.h> is available,
    and used in previously commited code
    (0f2b1e648156555a96ed54170e1b385a60010910, GH #23503).

@t-a-k, @khwilliamson, can you take a look? Thanks.

Metadata

Metadata

Assignees

Labels

Closable?We might be able to close this ticket, but we need to check with the reporterclang++ problemstype-buildRelates to building perl or a distribution we bundle.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions