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.
*** Issue 8710 has been marked as a duplicate of this issue. ***
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 }
This compiles without error on 2.064.