Wolf480pl on Nostr: Piggo :verified_horse: compilers do stupid optimizations based on supposed UB all the ...
Piggo :verified_horse: (nprofile…q955) compilers do stupid optimizations based on supposed UB all the time.
And this particular code seems to compile correctly* today:
https://godbolt.org/z/E5YccWc31but I'm not asking if it compiles correctly* today.
I'm asking if the C standard requires the compiler to compile it correctly* or if it allows a stupid optimization.
*by "correctly" I mean preserving the null check before the dereference
Published at
2025-02-14 18:12:14Event JSON
{
"id": "0bbe231f7f97ef96e47021ea9c6b7bc39e7e9e353251b2d15026b28032da1655",
"pubkey": "f3eaf89270fc0355ce2a91d69bca71c340a0a38b7c833b8ff837e8aaa0c98e82",
"created_at": 1739556734,
"kind": 1,
"tags": [
[
"p",
"aac4cd54dd3c8e2dc2d2472d27f255a9710188185f7a152f9626cd8c1d66c750",
"wss://relay.mostr.pub"
],
[
"e",
"a0a45fb41d1d1fd8c34a27f8eb32fe6f1e6ff315ef6916d875782f0170b24cf7",
"wss://relay.mostr.pub",
"reply"
],
[
"proxy",
"https://mstdn.io/users/wolf480pl/statuses/114003590143696734",
"activitypub"
]
],
"content": "nostr:nprofile1qy2hwumn8ghj7un9d3shjtnddaehgu3wwp6kyqpq4tzv64xa8j8zmskjgukj0uj449csrzqctaap2tukymxcc8txcagqrjq955 compilers do stupid optimizations based on supposed UB all the time.\n\nAnd this particular code seems to compile correctly* today: https://godbolt.org/z/E5YccWc31\n\nbut I'm not asking if it compiles correctly* today.\n\nI'm asking if the C standard requires the compiler to compile it correctly* or if it allows a stupid optimization.\n\n*by \"correctly\" I mean preserving the null check before the dereference",
"sig": "96affc8447d8adca5a73cea7069ea7c4cf9b14c6f766b4871d5f0e25e5178494721717c8b1a01c74a0aa448ebf6dfbd4d8d40dea22c9f0af32616c34723a8d68"
}