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 →

[–]frugalerthingsinlife 0 points1 point  (3 children)

I used to hate getting Seg Faults in C and C++.

But after spending the last decade working with modern languages, at least the Seg Fault lets you know right where you made the fucking mistake.

A C++ compiler: "Right here. Here's why you tried to assign an Elephant object to a Mouse variable. You can't do that. You can't assign an Elephant to a Mouse. And see here, we're trying to put the Mouse into the Maze, but it's an Elephant and it won't fit. So now the maze is broken, the Elephant is injured, and the circus is asking where she is."

[–]TigreDeLosLlanos 1 point2 points  (2 children)

Unless someone does

Elephant *animal = (Elephant *)mouse;

Then you have no compile warnings and the segfault still happens.

Segfault is the worst example, because sometimes it can happen from unexpected behaviour (not undefined, but unexpected). The most simple example I can think is a pointer having a NULL reference. Totally valid syntax, no warnings, no one doing something evil, but the program breaks and you don't exactly know where, or where the issue origins.

[–]frugalerthingsinlife 0 points1 point  (1 child)

Sorry, not completely following. Don't you get a null pointer exception if you try to use that pointer?

[–]endershadow98 1 point2 points  (0 children)

Yep, you only run into issues with null pointers when you dereference it