Tuna on Nostr: int a; if (a + 1 > a) a++;is undefined behaviour. The if statement is a check to make ...
int a;
if (a + 1 > a)
a++;is undefined behaviour. The if statement is a check to make sure the increment operation occurs only when it does not wrap arround. The C compiler looks at the if condition and thinks "a+1 will always be greater than a. Wrapping is undefined so I don't have to care about that and assume it never happens" and optimises it out. Now the code becomes equivalent to int a;
a++;
Published at
2024-06-01 12:13:30Event JSON
{
"id": "60c4e909a910b742eff5973c4afec0ba783791f4cde84f20a422e065d85b224f",
"pubkey": "282c1797e2ed16f71165903cd4cc4814b56faf15376cf6256dca3c10de9f045d",
"created_at": 1717244010,
"kind": 1,
"tags": [
[
"proxy",
"https://mk.absturztau.be/notes/9tzn240falnb015g",
"activitypub"
]
],
"content": "\n\nint a;\nif (a + 1 \u003e a)\n a++;is undefined behaviour. The if statement is a check to make sure the increment operation occurs only when it does not wrap arround. The C compiler looks at the if condition and thinks \"a+1 will always be greater than a. Wrapping is undefined so I don't have to care about that and assume it never happens\" and optimises it out. Now the code becomes equivalent to int a;\na++;",
"sig": "71f96d0f3f90cf0020484d252868a84cc29b04df37006651a4c9ba5d41b638ebb5d2d66bb1fc73569e1569bfa5ba6353a84b27d421b4a64b24d9f7f253893ded"
}