Summary: Function return values cannot be used as "ref const"
           Product: D
           Version: 2.023
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

It seems that POD types cannot be directly used as "ref const" parameters when
returned from a function. Only direct struct initializers work - if those can
be considered as a function call. However, when using -inline and the called
function is inlined, the code works as expected.

The following code snippet will crash the compiler with:
  Internal error: ..\ztc\cod4.c 357

struct S {}
S x(){ return S(); }
void f(ref const S){}
void g(){ f(x()); }

When using a primitive data type, an error is generated instead:
  ?.d(4): function sxg.metrics.f (ref const const(int) _param_0) does not match
parameter types (int)
  ?.d(4): Error: x() is not an lvalue

alias int S;
S x(){ return 0; }
void f(ref const S){}
void g(){ f(x()); }


Reply via email to