digitalmars.D - assert(false) with -unittest
- Jens Mueller <jens.k.mueller gmx.de> Nov 16 2010
- dsimcha <dsimcha yahoo.com> Nov 16 2010
- Jens Mueller <jens.k.mueller gmx.de> Nov 16 2010
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
Nov 16 2010
== Quote from Jens Mueller (jens.k.mueller gmx.de)'s articleHi, 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.
Nov 16 2010
dsimcha wrote:== Quote from Jens Mueller (jens.k.mueller gmx.de)'s articleHi, 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
Nov 16 2010









dsimcha <dsimcha yahoo.com> 