r/programming • • May 24 '20

Analyzing The Simplest C++ Program (in gory detail)

https://oneraynyday.github.io/dev/2020/05/03/Analyzing-The-Simplest-C++-Program/
254 Upvotes

16 comments sorted by

6

u/[deleted] May 24 '20

Nice post ray

4

u/OneRaynyDay May 24 '20

Thanks bro

3

u/jaiakt May 25 '20

Jesus this is p sick. Also what's up ray lol. I knew that GitHub looked familiar

2

u/OneRaynyDay May 25 '20

Wait Jai is that you? LOL

2

u/jaiakt May 25 '20

Yea it's me lmao

19

u/Bergasms May 24 '20

That was pretty informative, thanks .

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

u/[deleted] 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

u/[deleted] 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

u/[deleted] May 24 '20

[removed] — view removed comment

7

u/OneRaynyDay May 24 '20

There’s a lot to unpack from this 😳😳

20

u/Cregaleus May 24 '20

This has to be the most bizarrely targeted troll account that I've come across