asserts in debug and release code

Justin Johansson no at spam.com
Wed Nov 4 14:27:43 PST 2009


With respect to the dmd -release compiler switch,
are assert statements meant to be compiled in release code?

Whilst the D1 spec says "The compiler may optionally not evaluate assert expressions at all.",
my intuition suggests that asserts would/should be evaluated (i.e. compiled in) when using -debug
compiler switch and not when using the -release switch (and if neither switch who knows what***)

*** And, btw, are -debug and -release mutually exclusive?

If one desires asserts to be evaluated only in -debug, is the correct thing to prefix
assert with debug as follows?

debug assert(cond);

Lastly, will assert/switch behaviour change in D2?

Thanks for all help,

Justin Johansson



More information about the Digitalmars-d-learn mailing list