[Issue 196] Static assertion involving typedef's base type fails strangely

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 1 02:25:42 PST 2007


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


thomas-dloop at kuehne.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|rejects-valid               |
         OS/Version|Windows                     |All




------- Comment #1 from thomas-dloop at kuehne.cn  2007-01-01 04:25 -------
The error message is incorrect, the assert should fail regardless.

#
# static assert (is (typeof(typeid(x).base) == int));
#

x -> (typedef int)
typeid(x) -> TypeInfo_Typedef(x)
typeid(x).base -> TypeInfo(int)
typeof(typeid(x).base) -> TypeInfo

Thus rewriting the above assert:
#
# static assert(is(TypeInfo == int));
#

To ensuring that a typedef's direct base type is an int:
#
# typedef byte X;
#
# static if(is(X == typedef) && is(X base == typedef)){
#    static assert(is(typeof(base) == int));
# }
#


-- 



More information about the Digitalmars-d-bugs mailing list