Bug 11611 – dmd -O causes std.stdio.File.byLine to segfault

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-26T16:18:00Z
Last change time
2013-11-26T16:55:16Z
Keywords
wrong-code
Assigned to
nobody
Creator
hsteoh

Comments

Comment #0 by hsteoh — 2013-11-26T16:18:13Z
CODE: ----- import std.stdio; void func(R)(R input) { } version=bad; void main() { try { version(bad) func(File("").byLine()); version(good) { auto f = File(""); func(f.byLine()); } } catch(Exception e) { } } ----- Compile command: ----- dmd -O test.d ----- Changing to version=good makes the problem go away; dropping the -O flag in the compile command also makes the problem go away. Based on this, it would appear that the problem comes from the optimizer interacting badly with the RefCounted implementations of File/ByLine. I'm unsure where the bug lies: in the optimizer, or in std.stdio; but my guess is that the optimizer is producing wrong code with structs containing dtors.
Comment #1 by hsteoh — 2013-11-26T16:55:16Z
Gah, seems to be duplicate of issue #10723. *** This issue has been marked as a duplicate of issue 10723 ***