Bug 937 – C-style variadic functions broken

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2007-02-07T10:15:00Z
Last change time
2014-02-16T15:24:05Z
Keywords
rejects-valid
Assigned to
nobody
Creator
tomas

Comments

Comment #0 by tomas — 2007-02-07T10:15:29Z
The code below should explain the problem sufficiently: ------------------------------------------------------- module vararg; // Works void a(...) { void* v = _argptr; } // Works void b(char* fmt, ...) { void* v = _argptr; } // Error: variadic functions with non-D linkage must have at least one parameter // which is correct extern(C) void c(...) { void* v = _argptr; } // Error: undefined identifier _argptr // vararg.d(22): Error: cannot implicitly convert expression (_argptr) of type int to void* // this is contrary to spec! extern(C) void d(char* fmt, ...) { void* v = _argptr; } void main() { a("a", 2, 3.0); b("b", 2, 3.0); c("c", 3, 3.0); d("c", 3, 3.0); }
Comment #1 by lio+bugzilla — 2007-02-09T02:01:25Z
I don't think this is a bug. For extern(C) you need std.c.stdarg, va_start..va_end..
Comment #2 by tomas — 2007-02-09T11:31:20Z
According to the spec the _argptr variable should be available... So it most definitely is!
Comment #3 by venix1 — 2010-08-26T17:26:47Z
While working on GDC, it was found this bug still exists in 1.063. The problem appears to be an if statement in func.c around line 811. "parameters" is not initialized until further down in the function. By substituting "f->parameters" the problem is resolved. ----------------------------------------------------------- // Original if statement if (f->linkage == LINKd || (parameters && parameters->dim)) // Modified if statement if (f->linkage == LINKd || (f->parameters && Parameter::dim(f->parameters))) GDC ticket. http://bitbucket.org/goshawk/gdc/issue/57/c-style-variadic-functions-broken
Comment #4 by bugzilla — 2011-02-20T13:11:53Z