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

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ส.ค. 2024

ความคิดเห็น • 14

  • @DPGrupa
    @DPGrupa 6 ปีที่แล้ว +49

    Its pretty obvious “awesome” is meant literally, as in “inspiring an overwhelming feeling of reverence, admiration, or fear”

  • @doBobro
    @doBobro 2 ปีที่แล้ว +7

    It's ridiculous how much code compiler can remove but you don't notice it in any way.

    • @sjswitzer1
      @sjswitzer1 ปีที่แล้ว +1

      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 ปีที่แล้ว +7

    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.

  • @aliancemd
    @aliancemd 6 ปีที่แล้ว +4

    51:47 - was that Niko Matsakis(sounded like him) at CppCon 2017? :)

  • @FalcoGer
    @FalcoGer ปีที่แล้ว

    @ 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)"

  • @michalmarszaleck
    @michalmarszaleck 4 ปีที่แล้ว

    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.

  • @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.

  • @kamilziemian995
    @kamilziemian995 ปีที่แล้ว

    Is "Behaviour" in the title of the video a typo or something else?

    • @hatemel-kharashy8856
      @hatemel-kharashy8856 ปีที่แล้ว +1

      it is still correct. "Behaviour" is UK english and "Behavior" is US english

  • @user-mv4oh8yp1y
    @user-mv4oh8yp1y 3 ปีที่แล้ว +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.

  • @notinlist
    @notinlist 6 ปีที่แล้ว +7

    24:34 OMG

  • @cicciobombo7496
    @cicciobombo7496 6 ปีที่แล้ว +2

    W- what did you just say?