digitalmars.D.bugs - [Issue 6893] New: Write of enum member represented with ubyte or ulong
- d-bugmail puremagic.com (33/33) Nov 05 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6893
- d-bugmail puremagic.com (11/11) Dec 02 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6893
- d-bugmail puremagic.com (8/8) Aug 22 2013 http://d.puremagic.com/issues/show_bug.cgi?id=6893
- d-bugmail puremagic.com (8/8) Aug 22 2013 http://d.puremagic.com/issues/show_bug.cgi?id=6893
- d-bugmail puremagic.com (8/11) Aug 22 2013 http://d.puremagic.com/issues/show_bug.cgi?id=6893
- d-bugmail puremagic.com (9/9) Aug 22 2013 http://d.puremagic.com/issues/show_bug.cgi?id=6893
- d-bugmail puremagic.com (16/16) Aug 22 2013 http://d.puremagic.com/issues/show_bug.cgi?id=6893
- d-bugmail puremagic.com (10/10) Aug 22 2013 http://d.puremagic.com/issues/show_bug.cgi?id=6893
- d-bugmail puremagic.com (11/11) Aug 24 2013 http://d.puremagic.com/issues/show_bug.cgi?id=6893
- d-bugmail puremagic.com (10/10) Aug 24 2013 http://d.puremagic.com/issues/show_bug.cgi?id=6893
http://d.puremagic.com/issues/show_bug.cgi?id=6893 Summary: Write of enum member represented with ubyte or ulong Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc --- Comment #0 from bearophile_hugs eml.cc 2011-11-05 04:05:46 PDT --- import std.stdio; enum E1 : uint { A, B, C }; enum E2 : ubyte { A, B, C }; enum E3 : ulong { A, B, C }; void main() { writeln(E1.C); writeln(E2.C); writeln(E3.C); } Output dmd 2.057head: C <error> Expected output: C C C -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 05 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6893 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com --- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-02 10:35:38 PST --- First two are ok now but the 3rd has become a massive template instance error (2.061). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 02 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6893 --- Comment #2 from hsteoh quickfur.ath.cx 2013-08-22 17:21:19 PDT --- The problem appears to be std.format.getNthInt, under "static if (isIntegral!...)": the code assumes that if a type is integral, it can be converted to int, but this is not true when the base type of the enum is ulong. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 22 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6893 --- Comment #3 from hsteoh quickfur.ath.cx 2013-08-22 17:31:41 PDT --- Hmm actually, there appears to be a bug somewhere else. The spec shouldn't be spec.DYNAMIC at all, since the default spec for enums is "%s". So something went wrong before this point. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 22 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6893 --- Comment #4 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-08-22 17:33:31 PDT --- (In reply to comment #3)Hmm actually, there appears to be a bug somewhere else. The spec shouldn't be spec.DYNAMIC at all, since the default spec for enums is "%s". So something went wrong before this point.Last time I tried to fix this I lost my head in the formatting jungle. Good luck! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 22 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6893 --- Comment #5 from hsteoh quickfur.ath.cx 2013-08-22 17:45:59 PDT --- Aha! I found the reason: getNthInt is called from a *compile-time* check, so even if the spec for enum is "%s", the compiler still has to compile this branch of the code. So the fix is for getNthInt to *statically* verify convertibility to int before attempting to call to!int. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 22 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6893 --- Comment #6 from hsteoh quickfur.ath.cx 2013-08-22 18:08:22 PDT --- Argh. I wish bugzilla allowed editing of comments... What I meant was: getNthInt is called from inside a *runtime* if-condition that evaluates to false when the spec is "%s" and the argument is a ulong enum, but since this if-condition can only be checked at runtime, getNthInt must be able to compile in that case. Currently it doesn't compile because it assumes isIntegral!T means T can be implicitly converted to int, which is not true if the argument is a ulong (or a ulong enum). So the fix is to replace isIntegral with is(typeof(to!int(...))) so that at compile-time the compiler will hardcode the function to throw an exception when an invalid argument is given. (It won't actually throw at runtime if the if-condition in the caller evaluates to false at runtime.) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 22 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6893 hsteoh quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #7 from hsteoh quickfur.ath.cx 2013-08-22 18:11:31 PDT --- https://github.com/D-Programming-Language/phobos/pull/1504 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 22 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6893 --- Comment #8 from github-bugzilla puremagic.com 2013-08-24 01:45:12 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/b680614e571c52b45cef9288e15ec3df601828a3 Add unittest for issue 6893. https://github.com/D-Programming-Language/phobos/commit/cbc684a001e53e3f1fc95ef6caddb0c66095e2f0 Merge pull request #1504 from quickfur/bug6893 Issue 6893 - Write of enum member represented with ubyte or ulong -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 24 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6893 monarchdodra gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |monarchdodra gmail.com Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 24 2013