D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 504 - foreach with a file failes
Summary: foreach with a file failes
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 major
Assignee: Walter Bright
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-14 06:52 UTC by Stefan Liebig
Modified: 2020-09-02 07:09 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Stefan Liebig 2006-11-14 06:52:09 UTC
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;
}
Comment 1 Stefan Liebig 2006-11-15 00:21:18 UTC
The problem does no longer appear with 0.174.
Comment 2 Matti Niemenmaa 2006-11-15 02:39:04 UTC
I suppose the bug report can go, then.
Comment 3 Dlang Bot 2020-09-02 07:09:25 UTC
dlang-community/dfmt pull request #505 "Keep line break after function attributes" was merged into master:

- e6e52cd4d13b77368fef1a78f7ae451a6fcc543e by Eugen Wissner:
  Keep line break after function attributes
  
  Fixes #504.

https://github.com/dlang-community/dfmt/pull/505