Thread overview |
---|
March 07, 2007 [Issue 1036] New: regression: invalid code generation for class literal expression unless -fPIC or -release is used | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=1036 Summary: regression: invalid code generation for class literal expression unless -fPIC or -release is used Product: DGCC aka GDC Version: unspecified Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P3 Component: glue layer AssignedTo: dvdfrdmn@users.sf.net ReportedBy: thomas-dloop@kuehne.cn # int main(){ # int status; # # int delegate() foo(){ # return &(new class # { # int dg(){ # return ++status; # } # } # ).dg; # } # # int delegate() bar = foo(); # # if(status != 0){ # assert(0); # } # # if(bar() != 1){ # assert(0); # } # # if(status != 1){ # assert(0); # } # # return 0; # } gdmd-0.23 run/c/class_26_B.d -ofx && ./x -> Error: AssertError Failure run/c/class_26_B.d(32) gdmd-0.23 run/c/class_26_B.d -fPIC -ofx && ./x -> success test case: http://dstress.kuehne.cn/run/c/class_26_B.d -- |
March 11, 2007 [Issue 1036] regression: invalid code generation for class literal expression unless -fPIC or -release is used | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1036 dvdfrdmn@users.sf.net changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #1 from dvdfrdmn@users.sf.net 2007-03-11 08:13 ------- Exiting from 'foo' invalidates the anonymous class' link to 'status'. The correct way to do this is to have a direct pointer to the outer stack frame: return &(new class { int *p_status; this() { p_status = & status; } int dg() { return ++ *p_status; } } ).dg; -- |
March 12, 2007 [Issue 1036] regression: invalid code generation for class literal expression unless -fPIC or -release is used | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1036 ------- Comment #2 from thomas-dloop@kuehne.cn 2007-03-12 00:31 ------- Thanks, fixed -- |
Copyright © 1999-2021 by the D Language Foundation