Last update December 10, 2006

Doc Comments /


Put your comments about the official/non-official page here.

Assertions are turned off in release mode

 A better solution is to make explicit what the D language does implicitly - put an assert there:

int foo(int k, Collection c) { foreach (int x; c) { if (x == k) return x + 1; } assert(0); }

Now, if the foreach does fall through, the error will be detected. Furthermore, it is self-documenting.

However, if assertions are turned off (for a release build) - it's back in "undefined" land again.

Better to add both, like in

return 0;

However, at the moment this is not possible since the return is "not reached" according to DMD ?


See the corresponding page in the D Specification: DigitalMars:d/warnings.html

FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: December 10, 2006 7:52 (diff))