1. 11

  2. 2

    This is rather odd, in that it uses the int main() construct (as it should) but then fails to return any value from main half the time.

    It’s a bad habit to not return values from functions which say they return values. C isn’t C++: There is no implicit return value here. I wonder if the author is clear on the difference between C and C++.

    1. 1

      There is another step which is sort of optimized away… but you can force it to re-appear with the -S gcc option

      The compiler, I believe originally generated assembler, which then was assembled into the object file.

      I think these days that steep as been optimized away and they are going direct to machine code. (I no longer see “as” running when I compile, but you used to in the Bad Old Days.)

      1. 1

        gcc (at least on my machine - version: Ubuntu 5.4.0-6ubuntu1~16.04.5) still compiles to assembler then uses as to assemble it. Afaik it’s pretty uncommon for a C compiler to generate machine code directly, instead producing assembler (gcc) or llvm IR (clang) by default.

        1. 1

          You’re right, I tested sloppily (looked casually at top and didn’t see it) but if I strace yes it, it runs “as”