| ▲ | masklinn 11 hours ago | |
Is that an old 'bot? because I noticed it was an old version of Clang, and I tried switching to the latest Clang which is hilarious: https://godbolt.org/z/fra6fWexM | ||
| ▲ | nneonneo 10 hours ago | parent | next [-] | |
Oh yeah the classic Clang behaviour of “just stop codegen at UB”. If you look at the assembly, the main function just ends after the call to endl (right before where the if test should go); the program will run off the end of main and execute whatever nonsense is after it in memory as instructions. In this case I guess it calls main again (??) and then runs off into the woods and crashes. I’ve never understood this behaviour from clang. At least stick a trap at the end so the program aborts instead of just executing random instructions? The x and y values are funny too, because clang doesn’t even bother loading anything into esi for operator<<(unsigned int), so you get whatever the previous call left behind in that register. This means there’s no x or y variable at all, even though they’re nominally being “printed out”. | ||
| ▲ | recursivecaveat 10 hours ago | parent | prev | next [-] | |
No I wrote it with the default choice of compiler just now. That newer result is truly crazy though lol. | ||
| ▲ | qbane 10 hours ago | parent | prev | next [-] | |
icc's result is interesting too | ||
| ▲ | afiori 11 hours ago | parent | prev [-] | |
This is gold | ||