This code crashes the compiler:
class E(uint N) { }
class Boom
{
typedef E!(5) ET;
public:
ET foo() const // Badness here!
{ return x[3]; }
ET[int] x;
}
void main()
{
auto b = new Boom();
b.foo();
}
Technically, it's invalid, because I'm returning a mutable member reference from a const member function. However, the error message is to crash the compiler. Note that if you replace ET with a builtin or a non-template class, it correctly emits the expected error. Not sure why the template type blows it up, but it does.
Dave
Comment #1 by clugdbug — 2009-07-06T00:46:47Z
I cannot reproduce this. Works for me DMD2.031 Windows. (crashes at runtime with a range error).
What compiler version are you using?
Comment #2 by clugdbug — 2009-09-22T06:04:13Z
This was crashing in 2.026, but fixed by 2.030.
Comment #3 by smjg — 2009-12-29T13:44:03Z
It may've been fixed now, but still, how is this accepts-invalid?