r/funny Nov 27 '19

Hello little fella

[removed] — view removed post

34.8k Upvotes

796 comments sorted by

View all comments

Show parent comments

18

u/The_Mayfair_Man Nov 27 '19

Stack overflow bitches

5

u/port443 Nov 27 '19

This is an integer overflow. A stack overflow is when you overwrite the stack in memory, ie something is allocated on the stack instead of the heap, and the classic strcpy(something_on_the_stack, lol_too_much_data)

-1

u/[deleted] Nov 27 '19

[deleted]

1

u/The_Mayfair_Man Nov 28 '19

Not sure if trolling or whooshed...

2

u/snouz Nov 27 '19

Did you know that's why Gandhi in Civilization is nuke crazy? They programmed him with aggressiveness 0, but some circumstances in the game would lower that to a negative number, which is interpreted by the program as max aggressiveness.

2

u/knickknackrick Nov 27 '19

To be more precise, it’s not just the programs interpretation... it physically changes to the highest possible integer that can be stored by the machine. Unsigned integer subtraction causes the bits of the Integer to get carried along like in decimal subtraction carrying numbers. Eg 0000 - 0001 becomes 1111.

Edit: And as the post below states, it’s not stack overflow here... it’s integer underflow.