hn.today

your C is not standard C

sebsite.pw8 points1 comments
Screenshot of your C is not standard C

A catalog of concrete mismatches between the C language as written in the standard and how common toolchains actually behave, focused on gcc/clang with glibc or musl. It argues that mainstream implementations routinely deviate in ways that break portability or surprise users: gcc/clang treat asm as an extension by default (making a standard-valid identifier reserved in practice); gcc hardcodes FLT_ROUNDS to 1 instead of reflecting runtime changes made by fesetround; many C standard floating-point pragmas are unimplemented (gcc largely ignores them, clang supports some c99 pragmas but not c23); glibc’s initstate violates POSIX by not returning NULL on error despite documenting POSIX behavior; clang wrongly treats qualifiers on function return types as significant; and musl ships an outdated stdarg.h that defines va_start in a way that prevents use of C23’s single-argument va_start even when the compiler supports it.

These incompatibilities have concrete consequences: strictly conforming C code may fail to compile or behave differently under default compiler settings, runtime floating-point behavior may be misreported, and library man pages may obscure actual implementation bugs. Some issues can be mitigated with compiler flags or conditional workarounds, but others stem from header shadowing (musl) or long-standing implementation choices (glibc/gcc/clang) and thus require awareness or changes in toolchains to achieve true standards conformance.

Read on sebsite.pw1 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.