Extracted and slightly reduced from the larger test file:
import std.c.stdio;
import core.exception;
struct S56
{
int x = 1;
this(int i) { printf("ctor %p(%d)\n", &this, i); }
~this() { printf("dtor %p\n", &this); }
}
int foo56()
{
throw new Throwable("hello");
return 5;
}
void test56()
{
int i;
int j;
try
{
i = S56(1).x + foo56() + 1;
}
catch (Throwable o)
{
printf("caught\n");
j = 1;
}
printf("i = %d, j = %d\n", i, j);
assert(i == 0);
assert(j == 1);
}
int main()
{
test56();
return 0;
}
On linux, caught is printed and the asserts are fine.
On osx, it's not, and they're not.
Comment #1 by braddr — 2011-07-02T10:25:04Z
Additionally, without the additional assert(j == 1) in this version of the code (which should be added to the full sdtor.d file), test56 is implicated in the current auto-tester failure where with -inline, on osx garbage is printed at the end of the test run, before the Success line at the bottom main.
My current reduction has it down to just test28 and test56. The extra garbage output varied a good bit through the reduction. Taking out the throw line, the problem disappears. Taking out other parts also makes the problem go away, so it's not firm evidence yet.
Comment #2 by bugzilla — 2011-07-02T11:53:42Z
Ah, I see what the problem is (stack alignment). Will see about fixing it.