www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2561] New: Function return values cannot be used as "ref const" parameters

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: ludwig 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()); }
---


-- 
Jan 07 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2561


ludwig informatik.uni-luebeck.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE




------- Comment #1 from ludwig informatik.uni-luebeck.de  2009-01-07 04:16
-------
Touches the same issue as the previous bug report #2560

*** This bug has been marked as a duplicate of 2560 ***


-- 
Jan 07 2009