r/ProgrammerHumor • • Jan 28 '23

Meme C++

Post image
53.9k Upvotes

1.5k comments sorted by

View all comments

840

u/BobSanchez47 Jan 28 '23

C++ is Segmentation Fault: core dumped

423

u/Sexy_McSexypants Jan 28 '23

“ok, you wanna tell me what went wrong and where?”

“no, fuck you, Segmentation Fault”

89

u/throw3142 Jan 28 '23

I just got a segmentation fault in Python :D

Fun times

It's 3 am, I should go to sleep

45

u/Valmond Jan 28 '23

Prolly in a third-party library.

94

u/CuriousProgrammer72 Jan 28 '23 edited Jan 28 '23

Prolly in a third-party library

That has C++ bindings lol.

→ More replies (1)

50

u/Sinomsinom Jan 28 '23

If you do stuff in python where 99.5% of the actual work isn't done in a library not written in python you're using the wrong language.

57

u/Seanxietehroxxor Jan 28 '23

Python: the best language to call into libraries written in completely different languages.

→ More replies (3)
→ More replies (11)
→ More replies (6)

0

u/[deleted] Jan 28 '23

[deleted]

→ More replies (6)

15

u/[deleted] Jan 28 '23

gcc file.c -g then gdb

40

u/bad_investor13 Jan 28 '23

Surprise! Now the program works!

9

u/fireflash38 Jan 28 '23

Break out the valgrind, because you have a bounds access issue.

→ More replies (1)
→ More replies (2)

10

u/[deleted] Jan 28 '23

If it crashes then you're happy. You can debug it. But C++ sometimes doesn't crash, it just does "something"

→ More replies (3)

28

u/ArthurM_R2 Jan 28 '23 edited Jan 28 '23

A lot of begginers struggle with debugging this. Segmentation fault is not specific to C or C++. In fact this is a runtime exception signalled by memory hardware. The compiler is not concerned with this at all, since it's job is to make your instructions executable. Whether some memory access is an access violation or not is only decided by the MMU once the OS tries to execute the specific instruction. As to what went wrong - segmentation fault is always related to memory access (dereferencing pointers, accessing array indices out of bounds, etc). The computer cannot tell you what part of the source code is at fault - after compilation the PC only executes machine code which has little to do with your source and nothing else. To find out what went wrong you can use a debugger such as gdb which keeps track of instruction-to-source mappings. Hope I helped!

Edit: beginners struggle with debugging, not segfaults themselves, everyone has their fair share of segfaults

→ More replies (3)
→ More replies (7)
→ More replies (5)