Thread overview
[Issue 937] New: C-style variadic functions broken
Feb 07, 2007
d-bugmail
Feb 09, 2007
d-bugmail
Feb 09, 2007
d-bugmail
Aug 27, 2010
Dan G.
Feb 20, 2011
Walter Bright
February 07, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=937

           Summary: C-style variadic functions broken
           Product: D
           Version: 1.005
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: tomas@famolsen.dk


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);
}


-- 

February 09, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=937





------- Comment #1 from lio@lunesu.com  2007-02-09 02:01 -------
I don't think this is a bug. For extern(C) you need std.c.stdarg,
va_start..va_end..


-- 

February 09, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=937





------- Comment #2 from tomas@famolsen.dk  2007-02-09 11:31 -------
According to the spec the _argptr variable should be available...

So it most definitely is!


-- 

August 27, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=937


Dan G. <venix1@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |venix1@gmail.com


--- Comment #3 from Dan G. <venix1@gmail.com> 2010-08-26 17:26:47 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=937


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2011-02-20 13:11:53 PST ---
https://github.com/D-Programming-Language/dmd/commit/888bd52ab4d07c132c38f231dfabea648bf94cba

https://github.com/D-Programming-Language/dmd/commit/8d2bf812530f51b40fe08c9b0f526b60575ae604

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------