digitalmars.D.bugs - [Issue 573] New: Segfault from version(release) statement
- d-bugmail puremagic.com (20/20) Nov 19 2006 http://d.puremagic.com/issues/show_bug.cgi?id=573
- Jarrett Billingsley (10/32) Nov 19 2006 You sure about that? assert(0) is treated as a special case, and when
- d-bugmail puremagic.com (14/14) Nov 20 2006 http://d.puremagic.com/issues/show_bug.cgi?id=573
- d-bugmail puremagic.com (8/8) Nov 20 2006 http://d.puremagic.com/issues/show_bug.cgi?id=573
- Walter Bright (4/7) Nov 20 2006 Not precisely an illegal instruction, but a HLT (or equivalent)
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (7/13) Nov 21 2006 On PowerPC it does a "trap" instruction which also has that effect:
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 digitalmars.com ReportedBy: daekharel 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. Strangely, if it is compiled with "-v=release", it runs without error. --
Nov 19 2006
<d-bugmail puremagic.com> wrote in message news:bug-573-3 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 digitalmars.com ReportedBy: daekharel 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.
Nov 19 2006
http://d.puremagic.com/issues/show_bug.cgi?id=573 daekharel gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID Whoops. Looks like I misinterpreted what -release does: it doesn't switch the "release" version flag, and it removes assertions (or at least simple ones like assert(0)), replacing them by stuff that causes segfaults. I'll assume there's a good reason for the segfault behavior (probably has something to do with assert(0) signifying unreachable code), but in any case, this bug is invalid. --
Nov 20 2006
http://d.puremagic.com/issues/show_bug.cgi?id=573 Ah, sorry, I guess I should have posted my reply here instead of on the newsgroups. assert(0) is treated as a special case, and when compiled in release mode, they are left in and execute an illegal instruction. --
Nov 20 2006
d-bugmail puremagic.com wrote:assert(0) is treated as a special case, and when compiled in release mode, they are left in and execute an illegal instruction.Not precisely an illegal instruction, but a HLT (or equivalent) instruction, which works like a break point when running it under a debugger.
Nov 20 2006
Walter Bright wrote:On PowerPC it does a "trap" instruction which also has that effect: Program received signal SIGTRAP, Trace/breakpoint trap. _Dmain () at halt.d:3 3 assert(0); (gdb) --andersassert(0) is treated as a special case, and when compiled in release mode, they are left in and execute an illegal instruction.Not precisely an illegal instruction, but a HLT (or equivalent) instruction, which works like a break point when running it under a debugger.
Nov 21 2006