4 ms·
> Clang's behaviour is likely a crash but anything can still happen. You act as if clang itself is random. Clang will do and handful of things none of them whi
by grandempire 2y ago
> Clang's behaviour is likely a crash but anything can still happen.
You act as if clang itself is random. Clang will do and handful of things none of them which will melt your computer.
A given implementation may choose to do anything. Clang and gcc on major operating systems do reasonable things.
> It is literally undefined.
Ok but I’m explaining why undefined is the right thing.
- jenadine 2y agoThe code generated by clang can do anything. Ok, clang will not directly melt my computer because clang just generates code, but imagine this: if (temperature_too_high) lower_temperature(); if somewhere else the code access invalid pointer, clang may decide to remove this condition altogether because it thinks it must be dead code, for example. And running this code will melt the computer even though the programmer thought this wouldn't be possible.
- grandempire 2y agoThat’s not true. A conforming implementation may chose to melt your computer - and you can choose to not use that implementation. But clang and gcc will never melt your Linux. Once again, a real life example where that is relevant is an embedded device with no memory protection. If you overwrite a buffer you can overwrite the OS code - breaking your computer and requiring you to flash the memory. It seems there is a lot of misguided accusations going around about who misunderstands UB.
- eru 2y ago> But clang and gcc will never melt your Linux. If you use gcc or clang to compile your kernel, they will happily melt your Linux.
- grandempire 2y agoIf you're referring to what might happen when you overwrite a buffer in privileged kernel code, yes - but that is true regardless of clang, gcc, or what the C standard says about UB.