Bug 10939 – Inconsistent stripping of "in" but not assert in release/unittest

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-01T01:07:05Z
Last change time
2024-12-13T18:11:07Z
Assigned to
No Owner
Creator
monarchdodra
Moved to GitHub: dmd#17608 →

Comments

Comment #0 by monarchdodra — 2013-09-01T01:07:05Z
//---- import core.exception; void main() in { assert(0); //Passes } body { int i = 0; assert(i != 0); //Error version (assert) throw new RangeError(); //Error too } //---- When run with "-unittest -release", then the "in" block is stripped out, but the asserts aren't. This is inconsistent. The "in" block should also remain. Also, *Arguably*, I think the version (assert) blocks should be stripped though: These can contain any kind of code, which does *more* than just tests (it can set pointers to 0, log things, deep deconstruct stuff, you name it), which we probably *specifically* don't want to run, since we are in a "release unittest".
Comment #1 by code — 2014-01-05T14:37:00Z
The question then becomes: What should _not_ be stripped with -release in -unittest mode?
Comment #2 by code — 2014-01-05T14:40:02Z
Erm, sorry, I managed to get that statement precisely the wrong way around. My point was that the question becomes what of the code affected by -release actually _should_ be stripped in -release -unittest mode if e.g. contracts are left in.
Comment #3 by k.hara.pg — 2014-01-05T22:33:09Z
Current behavior: If "-release" is specified, following code would be stripped normally: - invariant - in contract - out contract - assertions https://github.com/D-Programming-Language/dmd/blob/master/src/mars.c#L1107 But, if "-unittest" is specified at the same time, just only assertions will be re-enabled. https://github.com/D-Programming-Language/dmd/blob/master/src/mars.c#L1121
Comment #4 by robert.schadek — 2024-12-13T18:11:07Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17608 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB