Bug 294131 - stdbit.h does not define types required by C23 and C2y
Summary: stdbit.h does not define types required by C23 and C2y
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: standards (show other bugs)
Version: 16.0-CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Robert Clausecker
URL: https://reviews.freebsd.org/D56515
Keywords:
Depends on:
Blocks:
 
Reported: 2026-03-30 04:21 UTC by Collin Funk
Modified: 2026-05-02 02:52 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Collin Funk 2026-03-30 04:21:49 UTC
C23 § 7.18.1 states that "This header makes available the size_t type name (7.21) and any uintN_t, intN_t, uint_leastN_t, or int_leastN_t type names defined by the implementation (7.22)."

This is not the case on FreeBSD 16.0-CURRENT. Here is an trivial example program that should compile, but does not:

$ cat main.c 
#include <stdbit.h>
int
main (void)
{
  size_t v1 = 0;
  uint32_t v2 = 0;
  return v1 = v2;
}
$ cc main.c
main.c:5:3: error: use of undeclared identifier 'size_t'; did you mean 'sizeof'?
    5 |   size_t v1 = 0;
      |   ^~~~~~
      |   sizeof
main.c:5:13: error: expression is not assignable
    5 |   size_t v1 = 0;
      |   ~~~~~~~~~ ^
main.c:5:10: error: use of undeclared identifier 'v1'
    5 |   size_t v1 = 0;
      |          ^
main.c:6:3: error: use of undeclared identifier 'uint32_t'
    6 |   uint32_t v2 = 0;
      |   ^
main.c:7:10: error: use of undeclared identifier 'v1'
    7 |   return v1 = v2;
      |          ^
main.c:7:15: error: use of undeclared identifier 'v2'
    7 |   return v1 = v2;
      |               ^
6 errors generated.
Comment 1 Robert Clausecker freebsd_committer freebsd_triage 2026-04-09 22:26:59 UTC
Thank you for mentioning this, I totally forgot about this requirement.
Comment 2 Robert Clausecker freebsd_committer freebsd_triage 2026-04-19 19:49:59 UTC
Please find a prospective patch on Phabricator:

https://reviews.freebsd.org/D56515
Comment 3 commit-hook freebsd_committer freebsd_triage 2026-04-20 21:01:38 UTC
A commit in branch main references this bug:

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

commit c8c9324c94dfd4eeecbcfe4a1d3daa047420d3e5
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2026-04-19 12:36:34 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2026-04-20 20:59:54 +0000

    include/stdbit.h: declare size_t, (u)int*_t, and (u)int_least*_t

    These are required by ISO/IEC 9899:2024 § 7.18.1 ¶ 1 but were forgotten
    in my initial work.

    The current approach leaks intptr_t, uintptr_t, intmax_t, and uintmax_t
    through <sys/_stdint.h>.  This could be avoided using a more complicated
    approach if desired.

    PR:             294131
    Fixes:          6296500a85c8474e3ff3fe2f8e4a9d56dd0acd64
    Reported by:    Collin Funk <collin.funk1@gmail.com>
    Reviewed by:    imp
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D56515

 include/stdbit.h | 22 +++++++++++++++++++++-
 sys/sys/stdint.h |  3 +++
 2 files changed, 24 insertions(+), 1 deletion(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2026-04-27 00:30:37 UTC
A commit in branch stable/15 references this bug:

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

commit 16ed84d2b9a1c95b6e0aabd5b7976367b2997d00
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2026-04-19 12:36:34 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2026-04-27 00:29:49 +0000

    include/stdbit.h: declare size_t, (u)int*_t, and (u)int_least*_t

    These are required by ISO/IEC 9899:2024 § 7.18.1 ¶ 1 but were forgotten
    in my initial work.

    The current approach leaks intptr_t, uintptr_t, intmax_t, and uintmax_t
    through <sys/_stdint.h>.  This could be avoided using a more complicated
    approach if desired.

    PR:             294131
    Fixes:          6296500a85c8474e3ff3fe2f8e4a9d56dd0acd64
    Reported by:    Collin Funk <collin.funk1@gmail.com>
    Reviewed by:    imp
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D56515

    (cherry picked from commit c8c9324c94dfd4eeecbcfe4a1d3daa047420d3e5)

 include/stdbit.h | 22 +++++++++++++++++++++-
 sys/sys/stdint.h |  3 +++
 2 files changed, 24 insertions(+), 1 deletion(-)
Comment 5 Robert Clausecker freebsd_committer freebsd_triage 2026-05-01 10:20:25 UTC
Thank you for your report.
Comment 6 Collin Funk 2026-05-02 02:52:23 UTC
Thanks for the quick fix! I'm not able to test it since I was using a shared machine, but the patch looks correct.