www.digitalmars.com         C & C++   DMDScript  

D.gnu - [Issue 1683] New: Issue with variadic functions

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1683

           Summary: Issue with variadic functions
           Product: DGCC aka GDC
           Version: 0.24
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: glue layer
        AssignedTo: dvdfrdmn users.sf.net
        ReportedBy: mariusmuja gmail.com


GDC fails to compile the following code:

--------------
import std.stdio;
void test(TypeInfo[] arguments, void* argptr)
{
    writefln("test(TypeInfo[] arguments, void* argptr)");
}

void test(...)
{
    writefln("test(..)");
}

void test2(...)
{
    test(_arguments, _argptr);
}

void main()
{
    test2(1,2,3);
}
--------------

with the error message:

--------------
test_args.d:15: function test_args.test called with argument types:
        (TypeInfo[],char*)
matches both:
        test_args.test(TypeInfo[],void*)
and:
        test_args.test(...)
----------------

With DMD the above code compiles and the test_args.test(TypeInfo[],void*)
function is called.

This issue prevents the usage under GDC of several functions from the tango
library, such as:
Layout(T).sprint (T[] result, T[] formatStr, ...) and 
Layout(T).sprint (T[] result, T[] formatStr, TypeInfo[] arguments, ArgList
args)


-- 
Nov 21 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1683





------- Comment #1 from afb algonet.se  2007-11-22 01:07 -------
It works OK if you use the portable version of varargs:

import std.stdio;
import std.stdarg;
void test(TypeInfo[] arguments, va_list argptr)
{
    writefln("test(TypeInfo[] arguments, va_list argptr)");
}


-- 
Nov 21 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1683


mariusmuja gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




------- Comment #2 from mariusmuja gmail.com  2007-11-22 02:31 -------
Yes, it does.


-- 
Nov 22 2007