www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6892] New: Formatted write with specified length of enum member

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6892

           Summary: Formatted write with specified length of enum member
           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



import std.stdio, std.traits;
enum Foo { A };
void main() {
    writefln(">%12s<", "A");
    Foo[] foos = [EnumMembers!Foo];
    writefln(">%12s<", foos[0]);
}


Output dmd 2.057head:

           A<
A<
Expected output:
           A<
           A<
-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 05 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6892


Ali Cehreli <acehreli yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |acehreli yahoo.com



The following must be another manifestation of the same bug:

import std.stdio;

void main()
{
    enum E { e0 }

    foreach (format; [ "%s", "%d", "%u", "%3.7g", "%x", "%b" ]) {
        writefln(format, E.e0);
    }
}

Outputs:

e0
e0
e0
e0
e0
e0

Ali

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 27 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6892


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/phobos/pull/465

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 28 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6892




Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/b5256c57f64fa823ca8ba200d343674d6556c75c


Issue 6892 - Formatted write with specified length of enum member

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6892




Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/12571977d821a2e7e7a799012baea3e8f73dee0d
fix Issue 6892 - Formatted write with specified length of enum member

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 08 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6892


SomeDude <lovelydear mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear mailmetrash.com



PDT ---
On 2.059 Win32, the original test passes but the test of comment 1 throws an
exception:

PS E:\DigitalMars\dmd2\samples> rdmd bug.d
e0
0
0
std.format.FormatException E:\DigitalMars\dmd2\windows\bin\..\..\src\phobos\std\format.d(1178):
integral

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 20 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6892




The problem at comment 5 can be reduced to this:

import std.stdio;

void main()
{
    writefln("%f", 42); // COMPILATION ERROR
}

It looks like an integral cannot be matched to a floating point format
specifier. (The same problem with "%g", etc.)

I have mixed feelings about this. Although 42 is definitely not a floating
point type, it is implicitly converted to one according to language rules.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 20 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6892





 The problem at comment 5 can be reduced to this:
 
 import std.stdio;
 
 void main()
 {
     writefln("%f", 42); // COMPILATION ERROR
 }
 
 It looks like an integral cannot be matched to a floating point format
 specifier. (The same problem with "%g", etc.)
 
 I have mixed feelings about this. Although 42 is definitely not a floating
 point type, it is implicitly converted to one according to language rules.
This is not allowed in current std.format implementation. Original issue was already fixed, so I'll close this issue. If you think integer value should be formatted with "%f", please open new enhancement request. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 22 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6892


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 22 2012