digitalmars.D.bugs - [Issue 8374] New: One missed array literal interpretation as int[2]
- d-bugmail puremagic.com (29/29) Jul 10 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8374
- d-bugmail puremagic.com (14/14) Jul 10 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8374
- d-bugmail puremagic.com (20/20) Jul 10 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8374
- d-bugmail puremagic.com (27/32) Jul 10 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8374
- d-bugmail puremagic.com (10/10) Jan 16 2013 http://d.puremagic.com/issues/show_bug.cgi?id=8374
http://d.puremagic.com/issues/show_bug.cgi?id=8374 Summary: One missed array literal interpretation as int[2] Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc I am not sure, but I think this code is correct: struct Foo { int[2] bar; } const(int[2]) spam() { const Foo* x; return true ? x.bar : [10, 20]; } void main() {} But DMD 2.060alpha gives: test.d(6): Error: cannot implicitly convert expression (cast(const(int)[])(*x).bar) of type const(int)[] to const(int[2u]) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 10 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8374 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |INVALID 16:36:56 PDT --- The type of [1,2] is int[], not int[2]. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 10 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8374 timon.gehr gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED CC| |timon.gehr gmx.ch Resolution|INVALID | The [1,2] / [10,20] literal implicitly converts to int[2]. It is similar to the following: struct Foo{ short bar; } short spam() { const Foo* x; return true ? x.bar : 1; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 10 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8374The type of [1,2] is int[], not int[2].Usually in my bug reports I add some cases where the code works, to avoid troubles like this one. This works: struct Foo { int[2] bar; } int[2] spam() { Foo* x; return true ? x.bar : [10, 20]; } void main() {} This too works: struct Foo { int[2] bar; } const(int[2]) spam() { const Foo* x; const(int[2]) r = true ? x.bar : [10, 20]; return r; } void main() {} -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 10 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8374 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yebblies gmail.com Is this the same as issue 8277? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 16 2013