digitalmars.D.bugs - [Issue 1350] New: template, tuple or static foreach issue; wrong values
- d-bugmail puremagic.com (67/67) Jul 20 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1350
- d-bugmail puremagic.com (29/29) Apr 26 2010 http://d.puremagic.com/issues/show_bug.cgi?id=1350
- d-bugmail puremagic.com (23/23) Apr 26 2010 http://d.puremagic.com/issues/show_bug.cgi?id=1350
- d-bugmail puremagic.com (10/10) Jul 16 2010 http://d.puremagic.com/issues/show_bug.cgi?id=1350
- d-bugmail puremagic.com (10/10) Jul 16 2010 http://d.puremagic.com/issues/show_bug.cgi?id=1350
- d-bugmail puremagic.com (24/24) Jul 22 2010 http://d.puremagic.com/issues/show_bug.cgi?id=1350
- d-bugmail puremagic.com (12/12) Dec 27 2012 http://d.puremagic.com/issues/show_bug.cgi?id=1350
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 digitalmars.com ReportedBy: chris 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); } --
Jul 20 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1350 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|template, tuple or static |alias template, typeof, or |foreach issue; wrong values |tuple issue; wrong varags | |values --- Comment #1 from Don <clugdbug yahoo.com.au> 2010-04-26 00:57:58 PDT --- Reduced test case shows it has nothing to do with static foreach. import std.stdarg; void Goat(Callbacks ...)(void* argptr) { auto Cb = Callbacks[0]; // fails // alias Callbacks[0] Cb; // works static if (is(typeof(Cb) P == delegate)) static if (is(P Q == function)) alias Q CBArgTypes; Cb(va_arg!(CBArgTypes[0])(argptr)); } void foo(...){ Goat!( (int i) { assert(i==333); } )(_argptr); } void main() { foo(333); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 26 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1350 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|alias template, typeof, or |delegate inside tuple; |tuple issue; wrong varags |wrong values |values | --- Comment #2 from Don <clugdbug yahoo.com.au> 2010-04-26 01:55:37 PDT --- Even further reduced. Nothing to do with varargs. ------------- void Goat(Callbacks ...)() { alias Callbacks[0] Cb; Callbacks[0](333); // fails // Cb(333); // but this works } void main() { Goat!( (int i) { assert(i==333); } )(); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 26 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1350 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla kyllingen.net --- Comment #3 from Don <clugdbug yahoo.com.au> 2010-07-16 10:20:02 PDT --- *** Issue 4359 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 16 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1350 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sandford jhu.edu --- Comment #4 from Don <clugdbug yahoo.com.au> 2010-07-16 10:20:42 PDT --- *** Issue 4246 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 16 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1350 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|delegate inside tuple; |delegate literal inside |wrong values |tuple; wrong values --- Comment #5 from Don <clugdbug yahoo.com.au> 2010-07-22 02:26:16 PDT --- This is happening because the delegate literal is passed as an alias template parameter. This parameter never gets resolved properly. In the example below, the compiler thinks that the parent of the delegate literal is 'Goat', whereas the true parent is 'main'. The problem might be in TupleExp::semantic(): if an element of the tuple is a symbol, maybe it should be attempting to resolve it. -------- void Goat(Callbacks ...)() { Callbacks[0](333); // fails } void main() { Goat!( (int i) { assert(i==333); } )(); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 22 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1350 Maxim Fomin <maxim maxim-fomin.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |maxim maxim-fomin.ru Resolution| |FIXED --- Comment #6 from Maxim Fomin <maxim maxim-fomin.ru> 2012-12-27 08:07:55 PST --- Fixed in issue 8774 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 27 2012