www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2243] New: const bool = is(function literal), badly miscast

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: default_357-line 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.


-- 
Jul 24 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2243


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed dmd 1.035 and 2.019


-- 
Sep 02 2008