CppCon 2017: Piotr Padlewski “Undefined Behaviour is awesome!”

  Рет қаралды 35,345

CppCon

CppCon

Күн бұрын

CppCon.org
-
Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2017
-
Undefined behavior (UB) is one of the features of C++ that is both loved and hated. Every C++ developer cares about performance, which is why it is very important to understand what the compiler can optimize and what are the language guarantees. Many times programmers are too optimistic about what the compiler can optimize, or they waste time optimizing code by hand.
In this talk you will learn:
- what is the “as-if” rule
- why compilers know less than the programmer - the main problem with Translation Units
- why compilers optimize based on UB, but don't warn about it
- why Undefined Behavior can transcend time, removing your whole code without running 88mph
- why having a more constrained language is better - optimizations that you can’t do in C
-
Piotr Padlewski: masters student, University of Warsaw
-
Videos Filmed & Edited by Bash Films: www.BashFilms.com
*-----*
Register Now For CppCon 2022: cppcon.org/registration/
*-----*

Пікірлер: 15
@DPGrupa
@DPGrupa 6 жыл бұрын
Its pretty obvious “awesome” is meant literally, as in “inspiring an overwhelming feeling of reverence, admiration, or fear”
@doBobro
@doBobro 2 жыл бұрын
It's ridiculous how much code compiler can remove but you don't notice it in any way.
@sjswitzer1
@sjswitzer1 Жыл бұрын
Arguably true for code you write yourself. The problem comes from templates, which can generate a lot of code that really should be dead-code-eliminated. The back end has trouble knowing the difference.
@MaceUA
@MaceUA 3 жыл бұрын
Reminded me of one anti-pattern that I've seen in at least two projects in their legacy code: `if (this == NULL) return;`. Obviously, the compiler has the right to throw it all away, because `this` is not allowed to be null.
@BaardFigur
@BaardFigur 2 ай бұрын
CWnd::GetHwndSafe();
@aliancemd
@aliancemd 6 жыл бұрын
51:47 - was that Niko Matsakis(sounded like him) at CppCon 2017? :)
@FalcoGer
@FalcoGer 11 ай бұрын
@ 33:00 when i compile that with clang 10, it emits an ud2 instruction, or 0F0B. "Raise invalid opcode exception". When run, this will trigger a segfault with "illegal hardware instruction (core dumped)"
@nullplan01
@nullplan01 5 жыл бұрын
49:00 Regarding the memory allocation thing: You know, you can just turn on strict accounting (by turning off overcommit). That has other problems, though.
@michalmarszaleck
@michalmarszaleck 3 жыл бұрын
25:00 if it would not be static then that means, there could be somewhere extern in another compilation unit and initialization before main and it could not do this.
@kamilziemian995
@kamilziemian995 Жыл бұрын
Is "Behaviour" in the title of the video a typo or something else?
@hatemel-kharashy8856
@hatemel-kharashy8856 Жыл бұрын
it is still correct. "Behaviour" is UK english and "Behavior" is US english
@notinlist
@notinlist 6 жыл бұрын
24:34 OMG
@user-mv4oh8yp1y
@user-mv4oh8yp1y 3 жыл бұрын
Useful part: 16:17, 20:23-21:09, 29:51, 35:00-35:37, 43:34. 1. Your if statement about checking nullptr wil be considered by Compiler to check undefined behaviour. 2. Don't forget return statement at every branch. 3. Undefined Behaviour means assuming not happen, to speed up. In short: don't write smart (short) code then you will be fine.
@cicciobombo7496
@cicciobombo7496 5 жыл бұрын
W- what did you just say?
CppCon 2017: Klaus Iglberger “Free Your Functions!”
1:01:42
Ну Лилит))) прода в онк: завидные котики
00:51
C++ Code Smells - Jason Turner - CppCon 2019
58:35
CppCon
Рет қаралды 76 М.
What is Span in C# and why you should be using it
15:15
Nick Chapsas
Рет қаралды 247 М.
CppCon 2016: Jason Turner “Practical Performance Practices"
1:00:29
Дени против умной колонки😁
0:40
Deni & Mani
Рет қаралды 10 МЛН
Цифровые песочные часы с AliExpress
0:45
cool watercooled mobile phone radiator #tech #cooler #ytfeed
0:14
Stark Edition
Рет қаралды 7 МЛН
What model of phone do you have?
0:16
Hassyl Joon
Рет қаралды 72 М.