Bug 5702 – Out parameter with default value as null compiling unit test fails.
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-03-05T03:53:00Z
Last change time
2015-01-09T09:32:50Z
Assigned to
nobody
Creator
doob
Comments
Comment #0 by doob — 2011-03-05T03:53:46Z
The following code fails to compile:
void isEmail (out void* v = null) {}
unittest
{
isEmail;
}
With the error message:
test.d(1): Error: null is not an lvalue
This only happens when I compile with -unittest. The parameter has to be an out parameter, a default parameter and the default value has to be null. The type of the parameter doesn't matter as long as "null" is a valid value for the type.
Comment #1 by doob — 2011-03-05T03:56:43Z
If the parameter is "ref" the same error occurs.
Comment #2 by k.hara.pg — 2015-01-09T09:32:50Z
The default argument of ref/out parameter should be an lvalue. See also issue 7603.