Comment #0 by matti.niemenmaa+dbugzilla — 2007-06-15T11:03:54Z
One of those hard to summarize legibly, yet relatively simple, bugs:
void f(typeof(*y) z) {}
typeof(x)* y;
int x;
Replace typeof(x) or typeof(*y) with int or move f after y and the code compiles. As it is, it emits "Error: error: forward reference of typeof(x)" without a line number for the error, in both DMD 1.014 and 1.015.
Comment #1 by matti.niemenmaa+dbugzilla — 2007-06-15T11:11:25Z
I was going to file this as a separate Bug, but it seems it's just a wonky error message for essentially the same thing:
void f(typeof(*y) z) {}
typeof(&x) y;
int x;
The above code errors out with the senseless "Error: can only * a pointer, not a 'typeof(&x)'", but at least it comes with a line number pointing at the typeof(*y), unlike the original code which used typeof(x)*.
Comment #2 by matti.niemenmaa+dbugzilla — 2007-06-15T11:16:39Z
Further testing:
f isn't needed, "typeof(*y) z;" is enough.
However, in the original ("typeof(x)* y;") case, using only "typeof(*y) z;" without f causes a compiler crash (no error message). Hence I'm stepping up the severity.
Comment #3 by bugzilla — 2007-06-27T21:00:45Z
At least it gives a line number now.
Comment #4 by clugdbug — 2009-04-18T17:45:53Z
This seems to be fixed on DMD2.028 (although possibly because of some other patch I've made <g> -- that would indicate that it's a duplicate). Still segfaults on D1.042.
Comment #5 by bugzilla — 2009-05-01T06:46:42Z
I've fixed the seg fault in the upcoming 1.045 version, but the forward reference error remains.
Comment #6 by clugdbug — 2009-05-15T00:46:37Z
This is no longer an ICE, just one of the many rejects-valid forward reference issue.
Comment #7 by r.sagitario — 2010-03-27T06:05:49Z
Here's a patch, but I am not 100% sure, whether the scope is correct for the type aswell.
Index: expression.c
===================================================================
--- expression.c (revision 421)
+++ expression.c (working copy)
@@ -7432,6 +7432,7 @@
error("can only * a pointer, not a '%s'", e1->type->toChars());
return new ErrorExp();
}
+ type = type->semantic(e1->loc, sc); // correct scope?
rvalue();
}
return this;
Comment #8 by bugzilla — 2011-02-07T22:11:53Z
Compiles without error on 2.052 and 1.067
Comment #9 by clugdbug — 2011-02-07T22:35:39Z
Fix confirmed: this failed in 2.050 and 1.065 but is fixed in 2.051 and 1.066