John Regehr's Integers in C Quiz

Lobsters Hottest Tools

Summary

An archival version of John Regehr's C integers quiz, wrapped in JavaScript for browser compatibility, highlighting tricky undefined behavior and integer issues in C code.

<p><a href="https://lobste.rs/s/gl13es/john_regehr_s_integers_c_quiz">Comments</a></p>
Original Article
View Cached Full Text

Cached at: 05/21/26, 04:16 PM

# John Regehr's Integers in C Source: [https://acepace.net/integerQuiz/](https://acepace.net/integerQuiz/) ## Welcome to John Regehr's Integers in C quiz A long time ago,[John Regehr](https://twitter.com/johnregehr)wrote a very nice quiz about C integers\. He's a pretty awesome expert on undefined behavior and this quiz highlights the type of stuff you need to know when auditing C code\. A lot of times you’ll run into really strange scenarios which end up causing exploitable bugs later in the code\. The original version was taken down long ago for reasons of WordPress compatability\. I've taken an archival version and wrapped it in simple JavaScript that should work on all browsers\. A few clarification that came up from Twitter threads and reddit\. - All other things being equal, assume GCC/LLVM x86/x64 implementation\-defined behaviors\. If you enjoyed this quiz, please follow[John Regehr](https://twitter.com/johnregehr)on Twitter\. You're also invited to follow me[Ace Pace](https://twitter.com/ace__pace)\.

Similar Articles

Getting silly with C, part &((int*)-8)[3]

Lobsters Hottest

A humorous educational article covering C programming fundamentals such as forward declarations, operator precedence, unconditional jumps, and basic arithmetic with intentionally silly code examples.

No way to parse integers in C (2022)

Hacker News Top

The article criticizes C standard library functions for parsing integers (atol, strtol, strtoul, sscanf), explaining why most are broken and only strtol can be used correctly with careful error handling.

Thoughts On Integers (2023)

Lobsters Hottest

A blog post discussing the design of integer types in various programming languages, arguing that Rust's approach of forcing explicit sizing and signedness selection is superior to languages with a default `int` type.

a bunch of stuff i used to not know about K&R C

Lobsters Hottest

The article explores obscure details about pre-ANSI C (K&R C) including the absence of void, different floating point types, and simplified type specifier rules. It explains how the language's context-sensitive grammar was justified by single-pass compiler constraints.

C programmers commit fresh crimes against readability

Hacker News Top

The 2025 International Obfuscated C Code Contest winners are announced, featuring 23 entries including Adrian Cable's Subleq computer emulator that enables software preservation through a one-instruction set architecture.