Bug 290299 - C++26's <stdckdint.h> fails to compile in C++
Summary: C++26's <stdckdint.h> fails to compile in C++
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: standards (show other bugs)
Version: 14.3-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-standards (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-16 17:23 UTC by Thiago Macieira
Modified: 2026-02-10 15:29 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thiago Macieira 2025-10-16 17:23:23 UTC
14.3's /usr/lib/clang/19/include/stdckdint.h has:

/* If we're hosted, fall back to the system's stdckdint.h. FreeBSD, for
 * example, already has a Clang-compatible stdckdint.h header.
 *
 * The `stdckdint.h` header requires C 23 or newer.
 */
#if __STDC_HOSTED__ && __has_include_next(<stdckdint.h>)
#include_next <stdckdint.h>
#else

But /usr/include/stdckdint.h is unusable in C++ mode, despite being part of C++26.

See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121811 for a similar discussion.

$ cat /tmp/test.cpp
#include <stdckdint.h>
bool qAddOverflow(int v1, int v2, int *r)
{
    return ckd_add(r, v1, v2);
}
$ c++ -fsyntax-only -std=c++26 /tmp/test.cpp 
/tmp/test.cpp:4:12: error: use of undeclared identifier '_Bool'
    4 |     return ckd_add(r, v1, v2);
      |            ^
/usr/include/stdckdint.h:16:3: note: expanded from macro 'ckd_add'
   16 |         (_Bool)__builtin_add_overflow((a), (b), (result))
      |          ^
1 error generated.
Comment 1 Konstantin Belousov freebsd_committer freebsd_triage 2025-10-17 04:12:27 UTC
https://reviews.freebsd.org/D53149
Comment 2 commit-hook freebsd_committer freebsd_triage 2025-10-17 22:42:08 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=3c052bec12fcf09f81ba0760ebecec38e196d332

commit 3c052bec12fcf09f81ba0760ebecec38e196d332
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-10-17 03:49:14 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-10-17 21:48:30 +0000

    include/stdckdint.h: make the header compatible with C++

    by removing the cast to _Bool.  The _Bool type is not defined for C++,
    and the specification from the gcc info doc states that the return
    type of the  __builtin_{add,sub,mul}_overflow() is bool already.

    This is done instead of including stdbool.h to avoid namespace
    pollution, since defining bool from stdckdint.h simingly is not
    sanctioned by ISO/IEC 9899:2024.

    PR:     290299
    Reviewed by:    des
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D53149

 include/stdckdint.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Comment 3 Thiago Macieira 2025-10-18 15:14:30 UTC
Thank you.
Comment 4 commit-hook freebsd_committer freebsd_triage 2025-10-24 07:48:34 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=e54e24bcc7810ba96483504bbd8f32dac8f24895

commit e54e24bcc7810ba96483504bbd8f32dac8f24895
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-10-17 03:49:14 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-10-24 07:47:12 +0000

    include/stdckdint.h: make the header compatible with C++

    PR:     290299

    (cherry picked from commit 3c052bec12fcf09f81ba0760ebecec38e196d332)

 include/stdckdint.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-10-24 09:52:49 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9dda71d578ead7d3e32789060f079bfb58666d2d

commit 9dda71d578ead7d3e32789060f079bfb58666d2d
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-10-17 03:49:14 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-10-24 09:47:37 +0000

    include/stdckdint.h: make the header compatible with C++

    PR:     290299

    (cherry picked from commit 3c052bec12fcf09f81ba0760ebecec38e196d332)

 include/stdckdint.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2025-10-25 23:07:45 UTC
A commit in branch releng/15.0 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9c31c1a823580a2816f9e856b4f14307ff3b22b7

commit 9c31c1a823580a2816f9e856b4f14307ff3b22b7
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-10-17 03:49:14 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-10-25 22:10:19 +0000

    include/stdckdint.h: make the header compatible with C++

    Approved by:    re (cperciva)
    PR:     290299

    (cherry picked from commit 3c052bec12fcf09f81ba0760ebecec38e196d332)
    (cherry picked from commit e54e24bcc7810ba96483504bbd8f32dac8f24895)

 include/stdckdint.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2026-02-10 15:29:14 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9748212e619b7608ac50ad6d0a768b20d5c9fd0b

commit 9748212e619b7608ac50ad6d0a768b20d5c9fd0b
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-10-17 03:49:14 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-02-10 14:24:30 +0000

    include/stdckdint.h: make the header compatible with C++

    by removing the cast to _Bool.  The _Bool type is not defined for C++,
    and the specification from the gcc info doc states that the return
    type of the  __builtin_{add,sub,mul}_overflow() is bool already.

    This is done instead of including stdbool.h to avoid namespace
    pollution, since defining bool from stdckdint.h simingly is not
    sanctioned by ISO/IEC 9899:2024.

    PR:     290299
    Reviewed by:    des
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D53149

    (cherry picked from commit 3c052bec12fcf09f81ba0760ebecec38e196d332)

 include/stdckdint.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)