Bug 5289 – std.conv.parse!double() results in a segmentation fault.
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-11-29T03:28:00Z
Last change time
2015-06-09T05:14:53Z
Assigned to
nobody
Creator
issues.dlang
Comments
Comment #0 by issues.dlang — 2010-11-29T03:28:32Z
This program
import std.conv;
import std.stdio;
void main()
{
writeln(parse!double("1.0"));
}
results in a segfault. In fact, _every_ value that I've tried to parse to a double or a float has resulted in a segfault. Maybe there are some that work, but I haven't found them, and the ones that I need to work don't.
Comment #1 by b.helyer — 2010-11-29T03:55:04Z
It's because you're using a string literal. parse takes it's argument by ref, and advances the array. The string literal is not an lvalue, but is permitted by DMD anyway -- this is the real bug. If you put the string in a variable, it will work.
Comment #2 by bugzilla — 2010-11-29T05:03:01Z
*** This issue has been marked as a duplicate of issue 4309 ***