LmCast :: Stay tuned in

your C is not standard C

Recorded: Oct. 15, 2026, 1:09 a.m.

Original Summarized

your c is not standard c

sebsite

your c is not standard c
2026-10-12

The committee has created an unreal language that no one can or will actually use.
- Dennis Ritchie (out of context)

this is an incomplete list of some incompatibilities between c as it's written in the standard and c as it exists in the real world for people who use gcc/clang + glibc/musl.

asm
by default, gcc and clang recognize the asm keyword as an extension. this is not strictly conformant, because in standard c, asm is a valid non-reserved identifier. so code which conforms to the standard may not compile with gcc/clang with their default settings.

and like, whatever, that's fine, that's why -std exists, but 1. it's notable that compilers aren't conformant by default, and 2. why doesn't the standard just make asm a reserved word? c++ does that; i'm not sure why c doesn't.

FLT_ROUNDS
the standard specifies the FLT_ROUNDS macro in float.h as follows:


5.3.5.3.3p23:
The rounding mode for floating-point addition for standard floating types is characterized by the implementation-defined value of FLT_ROUNDS. Evaluation of FLT_ROUNDS correctly reflects any execution-time change of rounding mode through the function fesetround in <fenv.h>.

notably, the standard requires that the value dynamically changes with the runtime floating environment. gcc, however, always defines FLT_ROUNDS to 1 (rounds to nearest), regardless of the runtime rounding mode:

/* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown. */
/* ??? This is supposed to change with calls to fesetround in <fenv.h>. */
#undef FLT_ROUNDS
#define FLT_ROUNDS 1
clang defines a builtin for this (__builtin_flt_rounds()), but gcc doesn't, for some reason.

standard pragmas
at some point in the future i'm gonna make an entire blog post dedicated to just this, because i kinda find it fascinating. but the super duper short version is this:

the c standard specifies five standard pragmas to control the behavior of floating point arithmetic:

// added in c99:
// switch can be ON, OFF, or DEFAULT
#pragma STDC FP_CONTACT ON
#pragma STDC FENV_ACCESS ON
#pragma STDC CX_LIMITED_RANGE ON

// added in c23:
// direction can be FE_DYNAMIC, FE_DOWNWARD, FE_TONEAREST,
// FE_TONEARESTFROMZERO, FE_TOWARDZERO, FE_UPWARD, or some
// other implementation-defined value
#pragma STDC FENV_ROUND FE_DYNAMIC
#pragma STDC FENV_DEC_ROUND FE_DYNAMIC
however, over 27 years after c99 was standardized, gcc still doesn't support any of the standard pragmas. they're just no-ops in gcc.

some (but not all) of the functionality can be replicated with command-line flags, but those operate on the entire translation unit, whereas the pragmas can apply to individual functions and blocks.

clang mostly supports the c99 pragmas, but still doesn't support the c23 pragmas.

there's actually so much more to say about these. i will be writing more about them at some point, but rn i don't really have the motivation cuz it's such a big thing lol

qualifiers in function return types
the standard requires that qualifiers in function return types are discarded:


If, in the declaration "T D1", D1 has the form

D ( parameter-type-listopt ) attribute-specifier-sequenceopt

and the type specified for ident in the declaration "T D" is "derived-declarator-type-list T", then the type specified for ident is "derived-declarator-type-list function returning the unqualified, non-atomic version of T". The optional attribute specifier appertains to the function type.

but clang treats them as significant:

$ cat t.c
int f();
const int f();
$ clang t.c
t.c:2:11: error: conflicting types for 'f'
2 | const int f();
| ^
t.c:1:5: note: previous declaration is here
1 | int f();
| ^
1 error generated.
the two declarations should be identical, but clang thinks they're incompatible.

outdated va_start definition on musl
for some reason, musl provides its own versions of some headers which the compiler already provides itself. one of these is stdarg.h, which is required to be supported by freestanding implementations and so is virtually guaranteed to already be provided by the compiler. but because it's provided by musl, compilers will use that header instead of the builtin one.

this is a problem because musl's header is strictly worse than the builtin header. here's how musl defines va_start:

#define va_start(v,l) __builtin_va_start(v,l)
this definition is incorrect, because c23 allows the second argument to be omitted. it should be defined like this:

#if __STDC_VERSION__ >= 202311L
#define va_start(...) __builtin_c23_va_start(__VA_ARGS__)
#else
#define va_start(v,l) __builtin_va_start(v,l)
#endif
the result is that, when compiling for musl, c23's single-argument va_start can't be used, even if it's supported by the compiler.

see also

notes on how glibc and musl handle math errors (math_errhandling)
oh, apparently it's not possible to portably check for string-to-float conversion errors in standard c: a case where posix arguably specifies a family of functions incompatibly from standard c
neither gcc nor clang are compliant with standard c++: gcc and clang don't store language linkage information with function types in c++, contrary to what the standard requires
yet another place where a linux man page is inaccurate (containing a deleted section from this post!)

The provided text outlines significant incompatibilities and deviations between the formal C language standard and its real-world implementations provided by compilers like gcc and clang, as well as different standard library environments such as glibc and musl. These discrepancies highlight the gap between the written standard and practical compilation, particularly concerning features related to floating-point arithmetic, compiler pragmas, and function type qualifiers.

One notable inconsistency involves the assembly language keyword. While the standard C allows asm as a valid non-reserved identifier, default settings in gcc and clang treat it as an extension, leading to potential compilation failures that a conforming program might otherwise avoid. The author notes that if the standard were to reserve this term, it would resolve the issue, paralleling how it is handled in C++.

Regarding floating-point behavior, the specification details the FLT_ROUNDS macro, which defines the rounding mode for floating-point addition based on the implementation-defined value of FLT_ROUNDS. The standard requires this value to dynamically reflect changes occurring through functions like fesetround in fenv.h. However, gcc defaults FLT_ROUNDS to 1 (rounds to nearest) regardless of the runtime environment, failing to dynamically adjust as mandated by the standard. Furthermore, the availability and implementation of related features differ; clang provides a builtin for rounding functions, whereas gcc does not, suggesting differing levels of compliance.

The C standard also introduces several pragmas designed to control floating-point arithmetic behavior, such as FP_CONTACT, FENV_ACCESS, and CX_LIMITED_RANGE in C99, and FENV_ROUND and FENV_DEC_ROUND in C23. Despite these standards being established, the authors observe that over twenty-seven years later, gcc generally does not support these standard pragmas, effectively rendering them as no-ops in the compiler. Clang generally supports the C99 pragmas but still lacks support for the C23 pragmas. The text suggests that while command-line flags can achieve some functionality, pragmas offer a superior mechanism for applying control at the individual function or block level, which is often necessary.

Another point of divergence concerns how qualifiers in function return types are treated. The standard implies that qualifiers should be discarded in specific contexts, but clang treats them as significant, leading to conflicts when interacting with other declarations, as demonstrated by conflicting results when compiling code with declarations like int f() and const int f() using clang.

Implementation differences further complicate portability between systems. For instance, the musl libc implementation presents issues regarding the va_start definition. While musl defines va_start to call __builtin_va_start, the authors argue this is incorrect concerning C23, which allows omission of the second argument. The correct implementation according to C23 should involve conditional compilation to use __builtin_c23_va_start when the standard version indicates C23 or later, demonstrating how a specific library's adaptation might violate forward compatibility with the language standard.

Finally, the text touches upon broader issues regarding portability, noting that it is not possible to portably check for string-to-float conversion errors in standard C. Furthermore, the authors point out that gcc and clang do not adhere to the C++ standard regarding the storage of language linkage information with function types, and there are documented inaccuracies in certain Linux man pages, indicating systemic issues in maintaining standard compliance across tools and documentation.