Bug 8612 – ICE(struct.c) struct alignment failure for delegate in catch block referring to the catched exception

Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2012-09-02T14:55:00Z
Last change time
2013-10-06T23:35:23Z
Keywords
ice
Assigned to
nobody
Creator
fawzi

Comments

Comment #0 by fawzi — 2012-09-02T14:55:45Z
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 by maxim — 2013-05-06T11:41:38Z
*** Issue 8710 has been marked as a duplicate of this issue. ***
Comment #2 by jeremiep — 2013-09-07T14:39:24Z
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 by bugzilla — 2013-10-06T23:35:23Z
This compiles without error on 2.064.