Aussie AI
Unreachable code assertion
-
Book Excerpt from "Generative AI in C++"
-
by David Spuler, Ph.D.
Unreachable code assertion
This is an assertion failure that triggers when code that should be unreachable actually got executed somehow. The simple way that programmers have done this in the past is:
yassert(0); // unreachable
And you can finesse that a little with just a better name:
#define yassert_not_reached() ( yassert(false) ) ... yassert_not_reached(); // unreachable
Here's a nicer version with a better error message:
#define yassert_not_reached() \ ( aussie_yassert_fail("Unreachable code was reached", __FILE__, __LINE__) )
• Next: • Up: Table of Contents |
The new AI programming book by Aussie AI co-founders:
Get your copy from Amazon: Generative AI in C++ |