www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2221] New: Bug with typeof(*this) in template struct

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2221

           Summary: Bug with typeof(*this) in template struct
           Product: D
           Version: 1.032
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: wbaxter gmail.com


Here's the code:
-----
struct Struct(T)
{
    static if (is(typeof(T.nan))) {
        static const is_fptype = true;
    }
    else {
        static const is_fptype = false;
    }


    static if(typeof(*this).is_fptype)
    //static if((typeof(*this)).is_fptype) //<- fixes it
    {
        pragma(msg, "T is " ~ T.stringof);
        pragma(msg, typeof(*this).stringof ~ " is fp type");
    }
    else {
        pragma(msg, "T is " ~ T.stringof);
        pragma(msg, typeof(*this).stringof ~ " is NOT fp type");
    }

}

alias Struct!(float) Sf;

alias Struct!(int) Si;

-------

From compiling that I get the output:
"""
T is float
Struct!(float) is fp type
T is int
Struct!(float) is fp type
"""





The output expected is:
"""
T is float
Struct!(float) is fp type
T is int
Struct!(int) is NOT fp type
"""

And that is the output you get if you stick extra parentheses around
(typeof(*this)).

This was tested on D1.033.

Possibly related to: 
* http://d.puremagic.com/issues/show_bug.cgi?id=2219
* http://d.puremagic.com/issues/show_bug.cgi?id=2154


-- 
Jul 12 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2221


braddr puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|1.032                       |1.033




------- Comment #1 from braddr puremagic.com  2008-07-12 12:33 -------
Added 1.033 to the list of versions and updated the bug to reference it.


-- 
Jul 12 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2221


korslund gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         OS/Version|Windows                     |All




------- Comment #2 from korslund gmail.com  2008-11-04 03:30 -------
Also possibly related to:
http://d.puremagic.com/issues/show_bug.cgi?id=2359

The various typeof(this) bugs seems appear in 1.032 and onward, and not be
present in 1.031 and earlier. The changelog for 1.032 lists several items
relating to typeof, so it's reasonable to assume that one of the fixes
introduced this bug.


-- 
Nov 04 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2221


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |FIXED




--- Comment #3 from Don <clugdbug yahoo.com.au>  2009-09-04 03:07:29 PDT ---
This was fixed in 1.039/2.023, but not listed in the changelog. (it's the same
root cause as bug 2527).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 04 2009