Misconceptions About Loops in C
summary
Static analysis for C loops fails on many surprising edge cases: examples include Duff's device, macros that build reentrant state machines, do‑while loops with conditional exits, CFGs that remove back edges, inlining that creates multi‑loop exits, jump threading that shortcuts into chaotic control flow, and empty loop body errors that lead to null pointer crashes. The authors supply artifact testcases (DOI links), report running examples through CBMC and finding unexplained exponential behavior, and recommend APIs that return all entry points, explicit preconditions with error messages, cross‑phase loop tracking, and systematic tests.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 6:34Duff's device complexities
- 8:22Unconditional jumps myth
- 10:33Control flow loop pitfalls
- 10:53Nested loops inlining surprises
- 12:18Jump threading chaos
- 14:05Empty loops API risks
- 15:31Loop merging surprises
- 16:12Loop API recommendations
- 17:58Testing loop analysis cases
- 18:23Q&A loop analysis
- 19:25Q&A slides
related talks
01h 03m“Implementing `static` control flow in C++14"
01h 04mThe Most Popular Bugs and Code Smells in C and C++
01h 30mDangerous Optimizations in C and C++ Programming Languages
01h 01mSome Programming Myths Revisited
01h 02mImplementing `static` control flow in C++14
01h 01mBack to Basics: Debugging in Cpp
34mHidden in Plain Sight: Corner Case Defects
01h 27mDangerous Optimizations! in C++ - Part Deux
