compiler that has no defined behaviour. everything is UB. is this anything
23 / none gender with left girl / straya mate
shitposting and weirdo computer nerd stuff, but mostly shitpostiing
| ℹ️ This user can say it. |
| ⚠️ This user will never forget this place. |
Given the following C++ (not C!) input file:
#include <stdio.h>
int main() {
while (1);
}
void oopsies() {
printf("tee hee fucky wucky :3");
}
Compiling this with clang 13 or newer, with -O1 or higher, results in the output:
> ./compiled
tee hee fucky wucky :3
Godbolt reveals the following output:
main: # @main
oopsies(): # @oopsies()
push rax
mov edi, offset .L.str
xor eax, eax
call printf
pop rax
ret
.L.str:
.asciz "tee hee fucky wucky :3"
which is uhhhhh Yeah Thats Not Right
what i think is happening:
ret here since this wont terminatemain with no retis there like some undefined behaviour Spooky Activity going on here? why is it Do That? and why only for c++ and not c, where it correctly keeps the infinite loop?