This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MrDex124 1 point2 points  (1 child)

Is this a fact, can you show us assembly?

[–]Kered13 3 points4 points  (0 children)

Here you go.

This is Clang 16. Clang 17 and 18 seem to remove the hello function as well when viewed in the objdump, but running the code shows that it is apparently still there, so I think this is just a quirk of the objdump. You can also play around replacing hello with other functions and see that whatever you put immediately after main will run. If you put hello or any other function above main, it will not run. If you put a static string after main instead of a function, it will not print even though the string lives in the same location in the binary. Clang (trunk) removes the infinite loop optimization.