4514 – Regression: Cannot cast from X* to X

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4514 - Regression: Cannot cast from X* to X
Summary: Regression: Cannot cast from X* to X
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Linux
: P2 regression
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
Reported: 2010年07月26日 20:23 UTC by Leandro Lucarella
Modified: 2010年07月30日 07:40 UTC (History)
3 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Leandro Lucarella 2010年07月26日 20:23:23 UTC
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 Stewart Gordon 2010年07月27日 09:36:25 UTC
Since "this" doesn't appear in the code, I'd doubt that that's the cause.
Comment 2 Trass3r 2010年07月27日 10:33:32 UTC
Compiles fine with r589 D2.
Comment 3 Leandro Lucarella 2010年07月27日 11:04:29 UTC
(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 Stewart Gordon 2010年07月27日 11:30:20 UTC
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 Walter Bright 2010年07月29日 17:01:46 UTC
The fix for 3706 caused this regression.
Comment 6 Walter Bright 2010年07月29日 22:17:14 UTC
http://www.dsource.org/projects/dmd/changeset/590 
Comment 7 Leandro Lucarella 2010年07月30日 07:40:46 UTC
(In reply to comment #6)
> http://www.dsource.org/projects/dmd/changeset/590 
Thanks, r590 works fine for me.


AltStyle によって変換されたページ (->オリジナル) /