CppCon 2016: Chandler Carruth “Garbage In, Garbage Out: Arguing about Undefined Behavior..."
Channel:CppCon · Length:57:39 · Published:2016-10-06 · Views:93765
Summary
Chandler Carruth's CppCon 2016 talk tries to defuse the heated debate over undefined behavior in C and C++. He explains from the compiler writer's perspective why UB exists and how it enables optimization.
Why HN recommends it
HN points to it whenever undefined behavior comes up, as the best explanation of the reasoning behind UB, though some dispute its framing.
Chandler Carruth's talk on the subject was really useful for my own understanding of the reasoning behind UB — HN, 2018
C, C++, Rust, Go & systems languages · Software performance & optimization · Compilers, interpreters & program analysis
Subtitles (excerpt)
All right, so we're going to talk about undefined behavior. Uh, my name is Chandler Ruth. I work at Google. I work on C++ for Google. I work on clang and LVM, the compilers. And one thing that I've done recently is I've I've, you know, started to try and and talk with people about undefined behavior. Um, so how many folks here are a little bit afraid of undefined behavior in their source code? Everybody. How many folks here think that this font is too small when it comes to talking about undefined behavior and how scared they are? Is that is that getting closer? That was too small. All right. Still too small. I mean, there there's a lot of there are a lot of issues here, right? People are actually really kind of afraid of this. Um, and and I think it's something that, you know, we as a community need to try and deal with better. Uh, so so that's what this talk is is about. This talk is not going to try and justify all forms of undefined behavior. It's not going to try and, you know, remove all undefined behavior. The the primary goal of this talk is to help us actually think about undefined behavior in a more productive way. Now, the number one thing I dislike about undefined behavior is this obsession with
On Hacker News
One man's "broken code produced by the compiler" is another man's "excellently optimized code by the compiler". Where to draw the line is not always clear, but here's a very clear-cut example[1] where emitting a warning would be bad. If you don't want to watch the video, it's basically this: - the code technically contains undefined behavior, but it will never be actually triggered by the program… — moefh, 2023-08
Actually I discourage my colleague to use unsigned especially because they can overflow. The problem with overflow is that most of the time it is a program bug if there is an overflow that wasn't intended. Using signed arithmetic means that you can actually trap on overflow and catch these bugs (using fuzzing for instance). Chandler explained it nicely in his CPPCon 2016 talk "Garbage In, Garbage… — Joky, 2018-11
Chandler Carruth's talk on the subject was really useful for my own understanding of the reasoning behind UB: [VIDEO] — lyricaljoke, 2018-05
The generally recommended thing for catching & fixing this is: [LINK] CppCon has also had a lot of great talks on UB and why it is what it is, such as [VIDEO] — kllrnohj, 2018-03
ISO C99 actually defines multiple types of deviating behaviour. What you're describing is closer to implementation-defined behaviour than anything else. The three behaviours relevant in this discussion, from section 3.4: 3.4.1 implementation-defined behavior unspecified behavior where each implementation documents how the choice is made EXAMPLE An example of implementation-defined behavior is the… — atiedebee, 2026-02
Related videos
- Euler's formula with introductory group theory · 3Blue1Brown · 24:28
- Robocalypse Now: Using Deep Learning to Combat Cheating in Counter-Strike: Global Offensive · GDC Festival of Gaming · 1:05:25
- CppCon 2017: Matt Kulukundis “Designing a Fast, Efficient, Cache-friendly Hash Table, Step by Step” · CppCon · 59:33
- How Python was Shaped by leaky Internals, Armin Ronacher, Flask framework · Видео с мероприятий {speach! · 49:55
- Rich Harris - Rethinking reactivity · You Gotta Love Frontend · 36:45
- CppCon 2015: Andrei Alexandrescu “std::allocator...” · CppCon · 1:12:27
- Lexical Scanning in Go - Rob Pike · GoogleFOSSSydney · 51:17
- William Byrd on "The Most Beautiful Program Ever Written" [PWL NYC] · PapersWeLove · 1:31:05
- Preventing the Collapse of Civilization / Jonathan Blow (Thekla, Inc) · DevGAMM · 1:02:41
- "Performance Matters" by Emery Berger · Strange Loop Conference · 42:15
- The Thirty Million Line Problem · Molly Rocket · 1:48:55
- RustConf 2018 - Closing Keynote - Using Rust For Game Development by Catherine West · Rust Programming Language · 42:29
- Erlang Factory 2014 - That's 'Billion' with a 'B': Scaling to the Next Level at WhatsApp · Erlang Solutions · 49:15
- How Crash Bandicoot Hacked The Original Playstation | War Stories | Ars Technica · Ars Technica · 31:37
- "How NOT to Measure Latency" by Gil Tene · Strange Loop Conference · 42:59
- CppCon 2016: Jason Turner “Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17” · CppCon · 1:19:52