[Issue 1350] New: template, tuple or static foreach issue; wrong values
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jul 20 09:50:27 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1350
Summary: template, tuple or static foreach issue; wrong values
Product: D
Version: unspecified
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P3
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: chris at dprogramming.com
Gives the wrong value for i and writefln prints out extra garbage.
version=BROKEN output:
foo
(char[],int)CALLBACK int = 0
bar
correct output, when version is not set to BROKEN:
foo
CALLBACK int = 333
bar
Code:
import std.stdarg, std.traits;
void Goat(Callbacks ...)(TypeInfo[] arguments, void* argptr)
{
args_loop:
foreach(argti; arguments)
{
version(BROKEN)
{
foreach(Cb; Callbacks)
{
alias ParameterTypeTuple!(Cb) CBArgTypes;
if(typeid(CBArgTypes[0]) == argti)
{
Cb(va_arg!(CBArgTypes[0])(argptr));
}
}
}
else
{
alias Callbacks[0] Cb;
alias ParameterTypeTuple!(Cb) CBArgTypes;
if(typeid(CBArgTypes[0]) == argti)
{
Cb(va_arg!(CBArgTypes[0])(argptr));
}
}
}
}
import std.stdio;
void foo(...)
{
writefln("foo");
Goat!(
(int i)
{
writefln("CALLBACK int = %s", i);
}
)(_arguments, _argptr);
writefln("bar");
}
void main()
{
foo(333);
}
--
More information about the Digitalmars-d-bugs
mailing list