Thread overview
[Issue 7147] New: [CTFE] typeid() should be supported in CTFE
Dec 21, 2011
Don
Dec 21, 2011
Don
Apr 17, 2013
Walter Bright
Aug 16, 2013
Rainer Schuetze
December 21, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7147

           Summary: [CTFE] typeid() should be supported in CTFE
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: clugdbug@yahoo.com.au


--- Comment #0 from Don <clugdbug@yahoo.com.au> 2011-12-21 05:38:27 PST ---
static assert({
    TypeInfo xxx = typeid(Object);
    TypeInfo yyy = typeid(new Error("xxx"));
    return true;
    }());

The first typeid gives:
bug.d(7): Error: Cannot interpret & D17TypeInfo_C6Object6__initZ at compile
time

The second one gives:

bug.d(38): Error: dereference of invalid pointer
'Error("xxx",null,0u,null,null,null)'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 21, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7147


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
           Severity|normal                      |enhancement


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 17, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7147


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2013-04-17 14:00:26 PDT ---
https://github.com/D-Programming-Language/dmd/pull/1905

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 17, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7147



--- Comment #2 from github-bugzilla@puremagic.com 2013-04-17 14:01:30 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/5d3aff1cc85b89bceaf09c5efa3174f1c823a0e0 Fix issue 7147 typeid() should be supported in CTFE

Recognize the lowering which happens in the front-end, and change it to a reference to the static 'typeinfo' variable.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 16, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7147


Rainer Schuetze <r.sagitario@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r.sagitario@gmx.de


--- Comment #3 from Rainer Schuetze <r.sagitario@gmx.de> 2013-08-15 23:15:45 PDT ---
This code now raises an ICE:

struct S { }
static assert(typeid(S).init.length > 0);

Assertion failure: 'thisval && thisval->op == TOKclassreference' on line 4067 in file 'interpret.c'

If you use a class instead:

class C {}
static assert(typeid(C).init.length > 0);

imp.d(2): Error: static assert  (& D16TypeInfo_C3imp1C6__initZ.init.length >
0u) is not evaluatable at compile time

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