r/programming • u/OneRaynyDay • May 24 '20
Analyzing The Simplest C++ Program (in gory detail)
https://oneraynyday.github.io/dev/2020/05/03/Analyzing-The-Simplest-C++-Program/3
u/jaiakt May 25 '20
Jesus this is p sick. Also what's up ray lol. I knew that GitHub looked familiar
2
19
3
u/namotous May 24 '20
I never knew under the hood of the process even though been writing C++ for almost a decade. Thanks for the breakdown!
0
u/RandNho May 25 '20
https://photos.app.goo.gl/xBB4G61Kn7X98K119 This is how your site looks at my tablet.
No.
1
May 25 '20
[removed] — view removed comment
2
u/evaned May 25 '20 edited May 25 '20
The best you can say about that is that's implementation-defined in C; I don't read the C standard as allowing it even as implementation-defined behavior though I could be wrong, and C++ definitely doesn't. GCC and Clang both actually accept that for compilation in C mode (I would argue as an extension to the standard, again), but it then segfaults when you run it because there's no code, so I think it's pushing it to consider that a program. Both compilers reject it in C++, and recall that the title bills it as "the simplest C++ program"
1
May 25 '20
Don't compilers accept an empty file? Wouldn't that be the simplest program?
1
u/evaned May 25 '20
A (C/C++) compiler would be able to build an empty object file out of an empty source file, but the linker wouldn't be able to build a program out of it. It's not a complete program.
-55
May 24 '20
[removed] — view removed comment
7
20
u/Cregaleus May 24 '20
This has to be the most bizarrely targeted troll account that I've come across
6
u/[deleted] May 24 '20
Nice post ray