D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8612 - ICE(struct.c) struct alignment failure for delegate in catch block referring to the catched exception
Summary: ICE(struct.c) struct alignment failure for delegate in catch block referring ...
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P2 major
Assignee: No Owner
URL:
Keywords: ice
: 8710 (view as issue list)
Depends on:
Blocks:
 
Reported: 2012-09-02 14:55 UTC by Fawzi Mohamed
Modified: 2013-10-06 23:35 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Fawzi Mohamed 2012-09-02 14:55:45 UTC
Dmd 2.060

dmd: struct.c:227: static void AggregateDeclaration::alignmember(structalign_t, unsigned int, unsigned int*): Assertion `alignment > 0 && !(alignment & (alignment - 1))' failed.

compiling

---------------
module t;
//    extern(C) int printf(const(char)*,...);                                                                          

int main(char[][] argv){
    try {
    } catch(Exception e){
    auto dl=delegate void(){
        auto myE=e;
        //printf("%*s\n",e.toString()); // if one wants to guarantee non-outoptimization;
    };
    }
    return 0;
}

---------------

this is is a issue when porting my code from D1 to D2.
Comment 1 Maxim Fomin 2013-05-06 11:41:38 UTC
*** Issue 8710 has been marked as a duplicate of this issue. ***
Comment 2 Jeremie Pelletier 2013-09-07 14:39:24 UTC
A quick workaround is to call a function from the catch block which handles the delegate:

void main() {
    try throw new Exception("catch me");
    catch(Exception e) {
         doSomething(e);
         auto dg = { throw e; } // this delegate will crash dmd
    }
}

void doSomething(Exception e) {
     auto dg = { throw e; }; // this delegate won't crash dmd
}
Comment 3 Walter Bright 2013-10-06 23:35:23 UTC
This compiles without error on 2.064.