[Issue 5251] New: Const C file

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 21 16:32:50 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=5251

           Summary: Const C file
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2010-11-21 16:31:32 PST ---
I think this program is supposed to work, because fprintf() and fclose() don't
modify 'fout':


import std.c.stdio: fopen, fclose, fprintf;
void main() {
    const fout = fopen("test.txt", "w");
    fprintf(fout, "%d", 10); // ERR
    fclose(fout); // ERR
}



But DMD 2.050 shows the errors:

test.d(4): Error: function core.stdc.stdio.fprintf (shared(_iobuf)* stream, in
const(char*) format,...) is not callable using argument types
(const(shared(const(_iobuf))*),string,int)
test.d(4): Error: cannot implicitly convert expression (fout) of type
const(shared(const(_iobuf))*) to shared(_iobuf)*
test.d(5): Error: function core.stdc.stdio.fclose (shared(_iobuf)* stream) is
not callable using argument types (const(shared(const(_iobuf))*))
test.d(5): Error: cannot implicitly convert expression (fout) of type
const(shared(const(_iobuf))*) to shared(_iobuf)*

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


More information about the Digitalmars-d-bugs mailing list