Thread overview
[Bug 100] New: Assert statement error
Apr 11, 2006
d-bugmail
Apr 11, 2006
Walter Bright
--gc-sections vs exceptions
Apr 11, 2006
Tom S
Apr 12, 2006
Walter Bright
April 11, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=100

           Summary: Assert statement error
           Product: D
           Version: 0.153
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: dronten@gmail.com


assert statements is not behaving as they used to do.
Here is a short test program.

gcc version 4.0.3 (Ubuntu 4.0.3-1ubuntu3)
Linux ubuntu 2.6.15-18-686 #1 SMP PREEMPT Thu Mar 9 15:29:22 UTC 2006 i686
GNU/Linux

#!/bin/rdmd
import std.stdio;

void main() {
    char[] a = "";
    try {
        if (a.length != 66) {
            writefln("ASSERT NOW");
            assert(false);
        }
        writefln("What the f...");
    }
    catch {
        writefln("catch");
    }
}

--- Test run 1
~/Documents/src/d/test: dmd ass.d
gcc ass.o -o ass -lphobos -lpthread -lm -Xlinker --gc-sections
~/Documents/src/d/test: ./ass
ASSERT NOW
Segmentation fault


--- Test run 2
~/Documents/src/d/test: dmd -g ass.d
gcc ass.o -o ass -g -lphobos -lpthread -lm -Xlinker --gc-sections
~/Documents/src/d/test: ./ass
ASSERT NOW
What the f...


--- Test run 3 (with rdmd)
~/Documents/src/d/test: ./ass.d
ASSERT NOW


---Test run 4 (dmd 1.50)
~/Documents/src/d/test: dmd -g ass.d
gcc ass.o -o ass -g -lphobos -lpthread -lm
~/Documents/src/d/test: ./ass
ASSERT NOW
catch


-- 

April 11, 2006
When I run it, it works fine. I suggest trying to link without the --gc-sections flag, maybe that is causing the problem.
April 11, 2006
Exception handling doesn't work on Linux when linking with --gc-sections.


-- 
Tomasz Stachowiak  /+ a.k.a. h3r3tic +/
April 12, 2006
Tom S wrote:
> Exception handling doesn't work on Linux when linking with --gc-sections.

That's not good news. Sigh.