assert(false) with -unittest

dsimcha dsimcha at yahoo.com
Tue Nov 16 09:39:57 PST 2010


== Quote from Jens Mueller (jens.k.mueller at gmx.de)'s article
> Hi,
> assert(false) should generate the hlt instruction in release mode.
> I.e.
> assert.d:
> void hlt() {
> 	assert(false);
> }
> $ dmd -release -c assert.d
> $ obj2asm assert.o | grep -w hlt
> works. But
> $ dmd -unittest -release -c assert.d
> $ obj2asm assert.o | grep -w hlt
> fails.
> Can't one have hlt together with unittest? Is it a bug in the compiler
> or correct behavior?
> Jens

I think this is correct.  The -unittest switch implicitly turns on asserts, and as
far as I can tell makes the -release switch ignored.  This means that
assert(false) is no longer special and works just like a regular assert as per TDPL.

Is this a problem in practice?  If so, please explain.


More information about the Digitalmars-d mailing list