r/computerscience • • May 15 '25

Discussion Most underground and unknown stuff

Which kind of knowledge you think is really underground and interesting, but usually nobody looks up?

36 Upvotes

22 comments sorted by

View all comments

Show parent comment

2

u/Aaron1924 May 16 '25

you can often rely on how GCC treats UB unless you're targetting a niche platform or compiler

Clang tends to optimize code a lot more aggressively around UB compared to GCC, the following function for example is optimized to always return 2 by GCC, but Clang treats the return value as entirely undefined (godbolt)

int two() {
    int x;
    return (x + 2) - x;
}

Using GCC as a reference for what UB "should be ok" is not a good idea