Bug 4689 – Error: cast from const(int) to real not allowed in safe code

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-08-20T02:45:00Z
Last change time
2011-06-11T01:01:40Z
Assigned to
nobody
Creator
zan77137

Comments

Comment #0 by zan77137 — 2010-08-20T02:45:43Z
This code should be compiled: struct S{ int x; @safe const real getX(){ return cast(real)x; } } Error: cast from const(int) to real not allowed in safe code See also: http://lists.puremagic.com/pipermail/phobos/2010-August/001958.html (2010/08/20 0:08), Andrei Alexandrescu wrote: >>> Line 414: no need for @trusted, casting numbers is not unsafe. >>> >> >> Error: cast from const(long) to real not allowed in safe code > >Compiler bug. I wonder whether const has anything to do with (shouldn't).
Comment #1 by yebblies — 2011-06-11T01:01:40Z
*** This issue has been marked as a duplicate of issue 5088 ***