[Issue 504] New: foreach with a file failes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 14 04:52:11 PST 2006


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

           Summary: foreach with a file failes
           Product: D
           Version: 0.173
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: StefanLiebig at web.de


The following code (counting lines of given file) fails (Error: Access
Violation) with 0.173 but works fine with 0.172:

import std.stdio;
import std.stream;

int main(char[][] args) {

        BufferedFile inFile = new BufferedFile();
        try {
                inFile.open( args[ 1 ], FileMode.In ) ;

                // count the lines 
                int max;
                foreach ( ulong n, char[] line; inFile ) {
                        max = n;
                }

                printf( "%d", max );

        } finally {
                inFile.close();
        }

    return 0;
}


-- 




More information about the Digitalmars-d-bugs mailing list