[Issue 560] New: Cannot escape reference to variadic parameter

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Nov 18 07:55:07 PST 2006


http://d.puremagic.com/issues/show_bug.cgi?id=560

           Summary: Cannot escape reference to variadic parameter
           Product: D
           Version: 0.174
          Platform: PC
               URL: http://www.digitalmars.com/d/function.html
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid, spec
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: deewiant at gmail.com
OtherBugsDependingO 511
             nThis:


The following code is directly from the spec:

int test(int i ...)
{
    return i;
}

void main()
{
        test(3);
}

The spec claims that "[a]n implementation may construct the object or array
instance on the stack. Therefore, it is an error to refer to that instance
after the variadic function has returned". This would seem to allow doing this
for parameters which aren't object or array instances. Indeed, the spec gives
the above code as an example of how "[f]or other types, the argument is built
with itself".

I'd say DMD is in error here. I've yet to realise how "int test(int i ...)" is
any better or different from "int test(int i)", though.


-- 




More information about the Digitalmars-d-bugs mailing list