[Issue 2561] New: Function return values cannot be used as "ref const" parameters
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jan 7 02:12:37 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2561
Summary: Function return values cannot be used as "ref const"
parameters
Product: D
Version: 2.023
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: ludwig at informatik.uni-luebeck.de
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()); }
---
--
More information about the Digitalmars-d-bugs
mailing list