Authors: Jay Ghiron
Date: 2026-04-01
Submitted against: C23
Status: Open
The wording with freestanding in C23 does not seem to be as intended:
A conforming freestanding implementation shall accept any strictly conforming program in which the use of the features specified in the library clause (Clause 7) is confined to the contents of the standard headers
<float.h>,<iso646.h>,<limits.h>,<stdalign.h>,<stdarg.h>,<stdbit.h>,<stdbool.h>,<stddef.h>,<stdint.h>, and<stdnoreturn.h>. Additionally, a conforming freestanding implementation shall accept any strictly conforming program where:
- the features specified in the header
<string.h>are used, except the following functions:strcoll,strdup,strerror,strndup,strtok,strxfrm; and/or,- the selected function
memalignmentfrom<stdlib.h>is used.
(Clause 4 "Conformance" paragraph 7.)
The first sentence omits the header <stdckdint.h> from the list of
allowed standard headers, which seems unintended. The second sentence
seems to be intended to extend what is allowed in the first sentence,
but the way it is worded does not actually do that:
#include<stdlib.h>
void foo(){
memalignment(0);
}
#include<stdio.h>
void bar(){
puts("ok?");
}
The memalignment function is used, so the second sentence requires a
conforming freestanding implementation to accept this code.
A possible correction could involve deleting this text and marking
each header or function as being allowed in freestanding. It may also
be useful to allow including headers such as <stdio.h> if none of
the features in it are used, to make writing code that works with both
freestanding implementations and hosted implementations easier.
Though this would impose requirements on what freestanding
implementations can include in such headers.