Bug 4514 – Regression: Cannot cast from X* to X

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2010-07-26T20:23:00Z
Last change time
2010-07-30T07:40:46Z
Keywords
rejects-valid
Assigned to
nobody
Creator
leandro.lucarella

Comments

Comment #0 by leandro.lucarella — 2010-07-26T20:23:23Z
This worked in svn r584 (add -m32 switch): --- void g(void delegate(void*, void*) d); struct X { void f(void*, void*) {} void n() { g(&f); // line 8 } } --- But it breaks on posterior revisions. Well, r585 to r587 don't compile/link (I mean the compiler, not the test program); r588 and r589 compiles (the compiler), but the test doesn't compile anymore, with this error: t.d(8): Error: cannot cast from X* to X Maybe some bits of D2 (struct this being a reference?) has been accidentally "ported" to D1. I didn't tested with D2, though.
Comment #1 by smjg — 2010-07-27T09:36:25Z
Since "this" doesn't appear in the code, I'd doubt that that's the cause.
Comment #2 by hoganmeier — 2010-07-27T10:33:32Z
Compiles fine with r589 D2.
Comment #3 by leandro.lucarella — 2010-07-27T11:04:29Z
(In reply to comment #1) > Since "this" doesn't appear in the code, I'd doubt that that's the cause. I don't know how the compiler internals deals with this, but the error appears in a method, taking the address/delegate of other method, so "this" exists, even if implicit. And D2 works, which is consisten with this theory. But again, I'm just talking out of ignorance because I don't know the compiler internals, it was just a hint.
Comment #4 by smjg — 2010-07-27T11:30:20Z
I was going on the assumption that the _internal concept_ of "this" is the same in D1 and D2, and the difference is merely what the _keyword_ "this" means between the two versions. But you could well ask what obscure thought process the compiler is going through....
Comment #5 by bugzilla — 2010-07-29T17:01:46Z
The fix for 3706 caused this regression.
Comment #6 by bugzilla — 2010-07-29T22:17:14Z
Comment #7 by leandro.lucarella — 2010-07-30T07:40:46Z
(In reply to comment #6) > http://www.dsource.org/projects/dmd/changeset/590 Thanks, r590 works fine for me.