digitalmars.D - assert(false) with -unittest
- Jens Mueller (16/16) Nov 16 2010 Hi,
- dsimcha (5/21) Nov 16 2010 I think this is correct. The -unittest switch implicitly turns on asser...
- Jens Mueller (4/26) Nov 16 2010 Haven't thought about it. Found this by accident.
- bearophile (4/9) Nov 16 2010 We have recently discussed a related topic. That works according to the ...
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? JensI 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 articleI see.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? JensI 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.Haven't thought about it. Found this by accident. Jens
Nov 16 2010
dsimcha: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.We have recently discussed a related topic. That works according to the specs. But mixing the halt with asserts is not tidy and it's not good. The conclusion was that the design is bad, but apparently it's not bad enough to justify a fix. Bye, bearophile
Nov 16 2010