Bug 2243 – const bool = is(function literal), badly miscast

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2008-07-24T12:24:00Z
Last change time
2014-03-01T00:37:04Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
default_357-line

Comments

Comment #0 by default_357-line — 2008-07-24T12:24:30Z
Consider, if you will, the following code: // one would expect this to be true. // In fact, is returns 1, which is then .... somehow .. cast to false. const bool foo = is(typeof(function void() { })); pragma(msg, "Fails: ", foo.stringof); // Now _bar is an int. And 1. const _bar = is(typeof(function void() { })); // And here the conversion works: bar is true. const bool bar = _bar; pragma(msg, "Succeeds: ", bar.stringof); This hints at a deep and confusing bug, which luckily is unlikely to affect _much_ code, though the code it does affect, it does highly annoyingly. Verified on GDC/Linux and DMD/win32 by h3r3tic, thanks! This is somehow tied to the function literal: using is(typeof(0)) casts correctly to true.
Comment #1 by bugzilla — 2008-09-03T01:36:11Z
Fixed dmd 1.035 and 2.019