• marcos@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    10 hours ago

    for example, simply optimize it away

    Yeah, that example makes it reasonable. But the optimizer can do ridiculous stuff when it proves the loop never terminates and also assume it terminates.

    The most famous example of UB bullshit is when some compilers run code that is impossible to reach just because there’s an infinite loop on the file (not even in the same function).

    • henfredemars@lemdro.id
      link
      fedilink
      English
      arrow-up
      7
      ·
      9 hours ago

      The lovely part about UB is it’s non-causal. The compiler can go back in time and steal Halloween candy from you when you were five and still comply with the specification.