Bug 14418 – D-style Variadic Function example does not compile
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-04-06T12:28:00Z
Last change time
2015-06-18T16:54:30Z
Keywords
pull
Assigned to
nobody
Creator
secondaryAccount
Comments
Comment #0 by secondaryAccount — 2015-04-06T12:28:41Z
The example for a 'D-style Variadic Function' on http://dlang.org/function.html does not compile.
import core.vararg;
void test()
{
foo(3, 4, 5); // first variadic argument is 5
}
int foo(int x, int y, ...)
{
int z;
z = va_arg!int(_argptr); // z is set to 5
}
dmd 2.067.0 output [ dmd -main filename.d ]:
Error: function [modulename].foo has no return statement, but is expected to return a value of type int
same with gdc (frontend 2.065) and ldc (2.066.1).
Possible fixes:
- make foo void
- add 'return z;'