[Issue 2243] New: const bool = is(function literal), badly miscast

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jul 24 10:24:31 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2243

           Summary: const bool = is(function literal), badly miscast
           Product: D
           Version: 1.033
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: default_357-line at yahoo.de


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.


-- 



More information about the Digitalmars-d-bugs mailing list