Stack overflow / recursive expansion with alias this

Timon Gehr timon.gehr at gmx.ch
Tue Apr 24 03:45:37 PDT 2012


On 04/23/2012 11:29 PM, Namespace wrote:
> I have this code:
>
...
>      T _get() {
>          return this._value;
>      }
>
>      const(T) _get() const {
>          return this._value;
>      }
>

You missed the 'immutable' and 'inout cases.
Just use inout(T) _get() inout { return _value; } instead of the two 
declarations you have.

> ...
> And therefore i get the same error, as if i wrote "return
> NotNull!(Foo)(this);" instead of "return assumeNotNull(this);", in the
> "_convert" method of NotNull. The Output is "Stack overflow". I think
> that comes from recursive calls which fills the stack? Is that a bug?
>

Yes.


More information about the Digitalmars-d-learn mailing list