HeadlinesBriefing favicon HeadlinesBriefing.com

C3 Dumps Unsigned After Five-Year Flaw

Hacker News •
×

C3 language admits a five-year mistake by switching from unsigned to signed sizes. The systems programming language, following C tradition, discovered that unsigned sizes create subtle bugs like infinite loops and broken comparisons. Developers must now navigate this fundamental type system change to avoid unexpected behavior in their code.

Unsigned types caused real problems in C3, particularly with expressions like (foo + a) % 2 producing surprising results when values exceeded INT_MAX. Ring buffer calculations with unsigned offsets became error-prone, with no way for the compiler to detect incorrect wrapping behavior. These bugs stem from a single decision that unsigned should be the default for sizes.

Signed sizes offer safer boundaries and fewer surprising behaviors, as evidenced by languages like Java and Go that avoided unsigned types entirely. While unsigned provides double the positive range, code in that range often contains bugs, and unsigned overflow produces plausible but incorrect results. The change reflects a broader recognition that type safety trumps theoretical range advantages.