assert(false) with -unittest
Jens Mueller
jens.k.mueller at gmx.de
Tue Nov 16 09:48:52 PST 2010
dsimcha wrote:
> == 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.
I see.
> Is this a problem in practice? If so, please explain.
Haven't thought about it. Found this by accident.
Jens
More information about the Digitalmars-d
mailing list