r/cpp • • Mar 14 '12

A 64-bit C++ horse that can count

http://www.viva64.com/en/a/0043/
0 Upvotes

3 comments sorted by

2

u/Steve132 Mar 14 '12

I'm not sure I understand this article...to me it looks like he made code that had an obvious 64-bit error (writing to a value that could overflow) but didn't call it an error, instead calling it something else.

5

u/Rhomboid Mar 14 '12

The error is obvious when you see it in an extracted simple testcase like this, but it's not necessarily so simple to find when it's buried in a large application that uses various typedefs to obscure the underlying types. The point wasn't that this was an error, but rather that it was an error that only sometimes manifests, but works properly under certain circumstances, leading to a lot of head scratching when an unrelated change suddenly causes the program to crash due to the latent bug exposing itself.

1

u/[deleted] Mar 14 '12

sorry, i lold

Once Heracles was walking by a lake and there he saw Hydra. He ran up to her and cut her single head off. But instead of one head two more grew. Heracles cut them off too but 4 more appeared. He cut the 4 heads off - and there were 8 ones... So passed one hour, two hours, three hours... And then Heracles cut Hydra's 32768 heads off and Hydra died for she was 16-bit.