www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3846] New: Unexpected BufferedFile output

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

           Summary: Unexpected BufferedFile output
           Product: D
           Version: 2.040
          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 2010-02-23 17:59:12 PST ---
This D2 code:

import std.stream: BufferedFile, FileMode;
import std.conv: to;
void main() {
    auto fout = new BufferedFile("foo.txt", FileMode.Out);
    int x = 10;
    fout.write(to!(const(char)[])(x) ~ "\n");
    fout.close();
}


Generates this foo.txt file (bytes expressed in hex):

03 00 00 00 31 30 0a



This Python2.6 program:

fout = file("foo.txt", "w")
fout.write(str(10) + "\n")

Generates this foo.txt file:

31 30 0d 0a


So I don't know if the D code gives the right output.

---------------

Secondary problem, this line:
fout.write(to!(const(char)[])(x) ~ "\n");
can't be replaced by this simpler one, that doesn't work:
fout.write(to!string(x) ~ "\n");

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



--- Comment #1 from bearophile_hugs eml.cc 2010-10-29 17:33:10 PDT ---
The second problem is now fixed, this code compiles, see bug 2718 :


import std.stream: BufferedFile, FileMode;
import std.conv: to;
void main() {
    auto fout = new BufferedFile("foo.txt", FileMode.Out);
    int x = 10;
    fout.write(to!string(x) ~ "\n");
    fout.close();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 29 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3846


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 09 2011