assert(false)

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Thu Jun 20 13:47:55 PDT 2013


On 06/20/2013 09:28 PM, Ali Çehreli wrote:
> On 06/20/2013 12:48 PM, Joseph Rushton Wakeling wrote:
> 
>> Is it considered good/recommended practice to insert an assert(false) statement
>> in parts of the code that should be unreachable?  Or simply an optional choice
>> that may be useful for debugging?
> 
> And a reminder that assert(false) (and assert(0)) is never removed from code
> (even when other asserts are). So, they are always there to prevent the program
> from producing unexpected results.

OK.  I noticed them present in some code in Phobos, and there's a place in
RandomSample where one could reasonably expect to see one but there isn't right
now.  I was considering whether to include it in some patches I'm preparing.


More information about the Digitalmars-d-learn mailing list