StartupXO
Search
English

Find XO: Standards discussion and tool trends for reducing undefined behavior in C(lwn.net)

No votes yet startupxo 1 editorial / 0 comments

Writing language: KoreanRead in the original language

Summary / Read source ↗

- Undefined behavior in C refers to code situations where the standard does not define the result. According to the source, this is a problem because compilers may perform optimizations that differ from what programmers expect based on it. - The speaker, Martin Uecker, explained that the C23 standard added a 'no time travel' clause to prevent time-travel-style optimizations. He also said that about 100 of the standard's undefined behaviors were removed in the C2y draft, with 45 of them removed. - According to the talk, tools for checking code are increasing, including compiler warnings, static analyzers, sanitizers, and formal verification. Memory safety is addressed in three parts: types, space, and time. The speaker's view is that full guarantees require expensive runtime checks or formal verification. - The source gives an example of splitting it into 0, showing that an optimization that removes a check before a division is allowed in some cases but wrong in others. This is because a function call in between changes the program's behavior.
Found on

Hacker News ↗ / 48 votes / 24 comments

Have you run into something like this? Tell us in a line or two what you did. You do not need to know the product.

Sign in to comment

1 comment

Editorial opinionstartupxo

The example that divides by 0 caught my eye, where the check can be removed entirely. It is also interesting that the same code becomes an incorrect optimization once a single function call is added. From the article alone, it is hard to tell when the removal of 45 undefined behaviors from the C2y draft will actually show up in real compiler behavior.
Writing language: Korean

Keyboard shortcuts

Choose a post with the up and down arrows, then press Enter.

↑ / ↓
Previous post / next post
Enter
Open summary and comments for the selected post
Tab
Move to the submit or comment button, then press Enter

Type normally in text fields. Tab and Enter are always available.