Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
August 30, 2008 [Issue 2323] New: Internal error: taking address of a method of a temporary struct | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2323 Summary: Internal error: taking address of a method of a temporary struct Product: D Version: 2.018 Platform: PC OS/Version: Windows Status: NEW Keywords: ice-on-valid-code Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: snake.scaly@gmail.com Compiler reports an internal error if an address of a temporary struct's method is taken: ---- begin test.d void main() { struct A { void foo() {} static A opCall() {A a; return a;} } void delegate() x = &A().foo; } ---- end test.d >dmd test.d Internal error: ..\ztc\cgcs.c 358 Workaround is to use an explicit stack variable for A(): auto y = A(); void delegate() x = &y.foo; compiles and works correctly. -- |
May 27, 2009 [Issue 2323] ICE(cgcs.c): taking address of a method of a temporary struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2323 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch, wrong-code Version|2.018 |1.040 --- Comment #1 from Don <clugdbug@yahoo.com.au> 2009-05-27 05:43:58 PDT --- This bug also applies to D1. And it silently generates bad code if compiled with -O. Reduced test case: ---- struct A { void foo() {} } A bar() {A a; return a;} void main() { void delegate() x = &bar().foo; } --- Root cause: should not be able to make a delegate from something which isn't an lvalue (just as you can't take address of a function return). PATCH: add one line in expression.c, DelegateExp::semantic(Scope *sc) if (func->needThis()) e1 = getRightThis(loc, sc, ad, e1, func); + e1->toLvalue(sc, e1); // add this line } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 23, 2009 [Issue 2323] ICE(cgcs.c): taking address of a method of a temporary struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2323 --- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2009-06-22 22:27:23 PDT --- Sergey is right, and the fix is to create a temp on the stack, copy the struct in, and take the address of that. One line fix in e2ir.c. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 09, 2009 [Issue 2323] ICE(cgcs.c): taking address of a method of a temporary struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2323 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2009-07-09 02:46:38 PDT --- Fixed dmd 1.046 and 2.031 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation