Bug 8250 – dirEntries fails to generate file list when compiled with -inline

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-16T01:52:00Z
Last change time
2012-12-22T00:04:14Z
Keywords
wrong-code
Assigned to
nobody
Creator
callumenator

Attachments

IDFilenameSummaryContent-TypeSize
1156direntry.dImperfect test casetext/x-dsrc368

Comments

Comment #0 by callumenator — 2012-06-16T01:52:48Z
This code: auto dFiles = dirEntries("testimages/","*.png",SpanMode.shallow); foreach(d; dFiles) writeln(d.name); should generate a list of four filenames, however when compiled with -inline it generates none. In release mode with -O (not using -inline) it works fine. Windows 7 x64 using DMD32 2.059 (same thing happened with 2.058).
Comment #1 by joseph.wakeling — 2012-10-25T04:25:25Z
Created attachment 1156 Imperfect test case Imperfect test case which doesn't show the precise described behaviour, but nevertheless fails to correctly implement the required dirEntries filter, so may be useful in tracking down bug.
Comment #2 by joseph.wakeling — 2012-10-25T04:36:21Z
Sorry, the error in the above example is from inappropriate use of takeExactly. :-( dirEntries does indeed return an empty list, and when the correct subdir is put in place, it returns the list of files. So, it's not a minimal example of the bug or even related. However, I _am_ still experiencing this problem of an empty list due to a filter which _should_ return a non-empty list of files, and indeed does when compiled with ldmd2 -- but fails when compiled with latest from-GitHub dmd: auto fileList = dirEntries(testSetDir, "*.txt", SpanMode.shallow); foreach(DirEntry e; fileList) { ... } If I remove the "*.txt" filter (there are only .txt files in the directory) the fileList is correctly populated.
Comment #3 by joseph.wakeling — 2012-10-25T04:38:36Z
(In reply to comment #2) > However, I _am_ still experiencing this problem of an empty list due to a > filter which _should_ return a non-empty list of files, and indeed does when > compiled with ldmd2 -- but fails when compiled with latest from-GitHub dmd: To clarify: it fails when compiled with dmd -inline, but works correctly when -inline is omitted. With ldmd2 it works with or without the -inline flag.
Comment #4 by dlang-bugzilla — 2012-12-21T21:43:20Z
Full test case: --- import std.file; void main() { mkdir("test8250"); scope(exit) rmdirRecurse("test8250"); write("test8250/a.txt", "test"); bool found; auto dFiles = dirEntries("test8250/", "*.txt", SpanMode.shallow); foreach (d; dFiles) if (d.name == "test8250/a.txt") found = true; assert(found, "Can't find a.txt"); } --- Succeeds with: dmd -run bug8250.d Fails with: dmd -inline -run bug8250.d Will attempt to reduce Phobos dependency and refile.
Comment #5 by dlang-bugzilla — 2012-12-22T00:04:14Z
*** This issue has been marked as a duplicate of issue 9193 ***