http://d.puremagic.com/issues/show_bug.cgi?id=8665
Summary: auto function and implicit conversion in return
statement corrupt returned value
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: wrong-code
Severity: critical
Priority: P2
Component: DMD
AssignedTo: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Kenji Hara <[email protected]> 2012-09-15 20:31:19 PDT ---
>From digitalmars.d.leran forum:
http://forum.dlang.org/thread/[email protected]
Reduced test case:
auto foo(bool val)
{
if (val)
return 42;
else
return 1.5;
}
void main()
{
assert(foo(true) == 42); // assertion failure
assert(foo(false) == 1.5);
}
The return type of foo is double, but returning 42 is broken in runtime.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------