Skip to content
0:00 / 0:00

#nullpointerdereference#undefinedbehavior#c++

*(char*)0 = 0; - What Does the C++ Programmer Intend With This Code? - JF Bastien - C++ on Sea 2023

cpponsea

18K subscribers • 4 videos on Hallway

YouTube

Advanced. Deep dive for people who know the field.

335K views3 years ago1 recommendation

Systems programmingProgramming languagesC++Compilers and interpretersOperating systems

JF Bastien explores the implications of a null pointer dereference across C++ standards, compilers, operating system kernels, and hardware.

cpponsea.uk/ --- *(char*)0 = 0; - What Does the C++ Programmer Intend With This Code? - JF Bastien - C++ on Sea 2023 int main() { *(char*)0 = 0; } This is a very simple program. Some might find it offensive, but let’s enjoy ourselves instead. Let’s talk about this program for the next 60 minutes. Maybe we can make it less offensive, let’s first ask: “what did the programmer intend with this code?” We’ll discuss what it might mean to a programmer, maybe we could help them express intent better. We should also consider what different versions of the code mean to various language standards. Once we’ve figured that out, how do compilers reconcile programmer’s feelings with standards’ opinions? That’s nice, but let’s dig in more deeply and look at what various kernels think about everyone’s opinions. Then, let’s see what various hardware do about all of this mess. Of course we’ll talk about undefined behavior, but we’ll do so much more! We’ll travel up and down the stack, discussing in details everything that such a seemingly-simple program does. --- Slides: github.com/philsquared/cpponsea-slides/tree/master/2023 Sponsored by think-cell: think-cell.com/en/ --- JF Bastien JF is chief architect at Woven by Toyota. He chairs the evolution of the C++ programming language. JF has worked on a variety of compilers for a variety of programming languages, implementing language features, improving performance / security / safety, targeting novel architectures, and other fun things. See jfbastien.com --- C++ on Sea is an annual C++ and coding conference, in Folkestone, in the UK. - Annual C++ on Sea, C++ conference: cpponsea.uk/ - 2023 Program: cpponsea.uk/2023/schedule/ - Twitter: twitter.com/cpponsea --- YouTube Videos Filmed, Edited & Optimised by Digital Medium: events.digital-medium.co.uk #cpp​ #cpponsea​ #cppprogramming

Why it's here

1 person recommends this

What people say. Recommended as an excellent, deep-dive talk on undefined behavior, compilers, and hardware interaction.

jibsenon Lobsters • Recommends

*(char*)0 = 0; - What Does the C++ Programmer Intend With This Code?

u/Iggyhopperin r/C_Programming • Mentions

On “64 bit system pointers confusion ”

link to this video Some of it may be too in-depth, but I found this talk fascinating during the last half. TL;DW: Everything is a memory map contained inside another memory map.

u/ThankYouForCallingVPin r/C_Programming • Mentions

On “UB programs”

Let me introduce you to the amazing and insightful talk: *(char *)0 = 0;