Bug 6955 – Immutable Strings -> Doubles Fails At Runtime

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-11-15T12:04:00Z
Last change time
2014-06-06T18:24:37Z
Assigned to
nobody
Creator
dsimcha
Depends on
6962

Comments

Comment #0 by dsimcha — 2011-11-15T12:04:42Z
import std.stdio, std.conv; void main() { immutable val = "2"; to!double(val); } std.conv.ConvException@/home/dsimcha/dmd2/linux/bin64/../../src/phobos/std/conv.d(1749): Can't convert value `2' of type string to type double ---------------- ./test(double std.conv.toImpl!(double, immutable(char[])).toImpl(immutable(char[]))+0x74) [0x425e34] ./test(_Dmain+0x15) [0x4235c1] ./test(extern (C) int rt.dmain2.main(int, char**).void runMain()+0x17) [0x428cc7] ./test(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate())+0x2a) [0x42886e] ./test(extern (C) int rt.dmain2.main(int, char**).void runAll()+0x42) [0x428d1a] ./test(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate())+0x2a) [0x42886e] ./test(main+0xd3) [0x4287ff] /lib/libc.so.6(__libc_start_main+0xfd) [0x7f09c9b48c4d] This goes away if I change `immutable val` to `auto val`.
Comment #1 by dsimcha — 2011-11-16T18:04:01Z
This only happens with -O, so it's a codegen bug. I'll work on creating a test case for the underlying codegen bug in a separate report.
Comment #2 by andrej.mitrovich — 2013-01-21T18:51:30Z
Can't reproduce in 2.061. Please verify and close with WORKSFORME if fixed.
Comment #3 by justin — 2014-06-06T18:24:37Z
Tested on linux 64 bit (same as original report) with dmd 2.065, cannot reproduce.