www.digitalmars.com         C & C++   DMDScript  

D - assert when not all control paths return a value

reply "C" <dont respond.com> writes:
If i am bringing this back up sorry , the code sample below just dies with
assertion error, with no line number or file name .  For large projects this
could be a big pain , is it possible to make all these checks at compile
time, or remove the assertion ?

-------------------------------------------------
import c.stdio;

bit func( bit possiblyFalse ) { if ( possiblyFalse) return false; }

void main () {
 func(false);
}
-------------------------------------------------
C
Jan 02 2004
parent "Matthew" <matthew.hat stlsoft.dot.org> writes:
"C" <dont respond.com> wrote in message
news:bt5ea8$1ndc$1 digitaldaemon.com...
 If i am bringing this back up sorry , the code sample below just dies with
 assertion error, with no line number or file name .  For large projects

 could be a big pain , is it possible to make all these checks at compile
 time, or remove the assertion ?

It is, and it's a popular point of view. Alas, that popularity doesn't stretch to our compiler-walter, so we may have to just lump it.
 -------------------------------------------------
 import c.stdio;

 bit func( bit possiblyFalse ) { if ( possiblyFalse) return false; }

 void main () {
  func(false);
 }
 -------------------------------------------------
 C

Jan 02 2004