[Issue 573] New: Segfault from version(release) statement
Jarrett Billingsley
kb3ctd2 at yahoo.com
Sun Nov 19 17:17:24 PST 2006
<d-bugmail at puremagic.com> wrote in message
news:bug-573-3 at http.d.puremagic.com/issues/...
> http://d.puremagic.com/issues/show_bug.cgi?id=573
>
> Summary: Segfault from version(release) statement
> Product: D
> Version: 0.174
> Platform: PC
> OS/Version: Linux
> Status: NEW
> Keywords: wrong-code
> Severity: normal
> Priority: P2
> Component: DMD
> AssignedTo: bugzilla at digitalmars.com
> ReportedBy: daekharel at gmail.com
>
>
> void main() { version (release) {} else { assert(0); } }
>
> -------
> The above throws an AssertError, as it should, when compiled & linked
> normally
> and run. However, when compiled with the "-release" flag, it segfaults
> when run
> instead of doing nothing, as it should.
You sure about that? assert(0) is treated as a special case, and when
compiled in release mode, they are left in and execute an illegal
instruction.
> Strangely, if it is compiled with
> "-v=release", it runs without error.
AFAIK there is no "release" version defined when you use the -release flag.
Therefore, the code is doing exactly as it should -- it compiles in the
"else" clause in release mode, causing an exception when the program is run.
But when you manually define the "release" version, it skips the "else" and
leaves the assert out.
More information about the Digitalmars-d-bugs
mailing list