1. 7
  1.  

  2. 1

    Yes, UB is not completely without any merit. But it is the wrong default.

    bzip2 can compile with -fundefined-overflow or whatever to take advantage of optimization, exactly like -ffast-math which is not enabled by default. Everyone else should benefit from getting rid of overflow UB.

    1. 3

      Ah, but as soon as you say there is a default… you suddenly have defined the behaviour and we having a different conversation.

      As I keep hammering at people, everything we do has undefined behaviour and it’s a good thing.

      If you rip the cover off your PC and yank a random chip off the motherboard, you’re deep in the realm of Undefined Behaviour, and it would be foolish for the designers to sit there saying, “Hmm, what should the behaviour of this system be if the user yanks that chip out?”

      There are vast swathes of life where the answer is and should be “Don’t do that, and if you do, it’s your problem not mine”.

      1. 1

        Well, the actual default (in the absence of command-line flags explicitly requesting otherwise) is -O0 (for both gcc & clang as far as I know), so…everything is peachy?