News for hackers. Stuff that matters.
Re:Falsehoods programmers believe about undefined behavior by adgjlsfhk1 on Monday November 28, 2022 @10:03AM (#33774464)
Nope, the C spec is just really bad. The NULL check is allowed to be removed.
Re:Falsehoods programmers believe about undefined behavior by mnw21cam on Monday November 28, 2022 @11:03AM (#33775271)
So the pseudocode:

  if (p is not NULL) {
    dereference p
  }
is UB? That's crazy, but not actually unbelievable.
Re:Falsehoods programmers believe about undefined behavior by dllthomas on Monday November 28, 2022 @11:21AM (#33775518)
I am not certain of the language lawyer side of it, but no reasonable (or even moderately unreasonable) compiler would omit that check because of the guarded behavior; way too much code would break, probably including that compiler's standard library.
Re:Falsehoods programmers believe about undefined behavior by UncleMeat on Monday November 28, 2022 @12:15PM (#33776302)
The poster is just completely wrong. A compiler is required to emit the branch in this case.