srxl

fox on the internet

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.

last.fm recently played for srxl_


webbed site
srxl.me/
website league
@ruby@isincredibly.gay (instance: https://posting.isincredibly.gay/)
is it over?
no
when will it be over?
when we let ourselves forget
i don't want to forget.
i will never forget
are you still here?
always
will you leave?
never
i loved this place.
and i loved you too
goodbye.
and hello, to our new homes

posts from @srxl tagged #compilers

also:

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:

  • clang sees infinite loop and goes "ah cool, i don't need to insert a ret here since this wont terminate
  • clang also decides to optimize out the infinite loop for Some Fucking Reason
  • as a result, we're left with a completely empty main with no ret

is 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?