Thread overview |
---|
February 06, 2007 [Issue 932] New: static foreach in second template instantiation uses wrong tupleof | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=932 Summary: static foreach in second template instantiation uses wrong tupleof Product: D Version: 1.00 Platform: PC OS/Version: All Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: fvbommel@wxs.nl --- void Fields(C)() { foreach(i, a; typeof(C.tupleof)) { // fails for second instantiation: // "test.d(7): static assert (is(int == real)) is false" static assert(is(typeof(a) == typeof(C.tupleof)[i])); } } struct MyStruct1 { int afield; } struct MyStruct2 { real afield; } void main() { Fields!(MyStruct1); Fields!(MyStruct2); } --- Reduced from code by Kyle Furlong, posted at http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.bugs&article_id=10262 I tested this on v1.00 and v1.002-v1.005, all fail above assert. (keyword "wrong-code" because this causes wrong code generation, though with the static assert it of course doesn't compile. See the original example (at link above) for a program that compiles and produces wrong code) -- |
April 05, 2007 [Issue 932] static foreach in second template instantiation uses wrong tupleof | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=932 ------- Comment #1 from thomas-dloop@kuehne.cn 2007-04-05 11:39 ------- Added to DStress as http://dstress.kuehne.cn/run/f/foreach_38_A.d http://dstress.kuehne.cn/run/f/foreach_38_B.d http://dstress.kuehne.cn/run/f/foreach_38_C.d -- |
May 25, 2009 [Issue 932] static foreach in second template instantiation uses wrong tupleof | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=932 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |clugdbug@yahoo.com.au Resolution| |INVALID --- Comment #2 from Don <clugdbug@yahoo.com.au> 2009-05-25 04:31:14 PDT --- This is an invalid bug. It fails because: static assert(is( typeof(a))); will always fail (a evaluates to 'int') inside a static foreach. Correct code would be: static assert(is(typeof(C.tupleof)[i] == a)); and that passes on DMD1.045 and 2.030. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation