[Issue 2571] const/invariant/immutable static arrays: const(T)[N] and const(T[N]) are the same, but DMD treats them as different

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 10 08:48:13 PST 2009


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


smjg at iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|const static arrays:        |const/invariant/immutable
                   |const(T)[N] and const(T[N]) |static arrays: const(T)[N]
                   |are the same, but DMD treats|and const(T[N]) are the
                   |them as different           |same, but DMD treats them as
                   |                            |different




------- Comment #1 from smjg at iname.com  2009-01-10 10:48 -------
The type should be reported as const(char[26]) in either case.  And here's
another case of the same basic bug:

----------
invariant(const(char)[26]) abc1 = "abcdefghijklmnopqrstuvwxyz";
const(invariant(char)[26]) abc2 = "abcdefghijklmnopqrstuvwxyz";

pragma(msg, typeof(abc1).stringof);
pragma(msg, typeof(abc2).stringof);
pragma(msg, (invariant(const(char)[26])).stringof);
pragma(msg, (const(invariant(char)[26])).stringof);

pragma(msg, is(typeof(abc1) : typeof(abc2)).stringof);
pragma(msg, is(typeof(abc2) : typeof(abc1)).stringof);
pragma(msg, is(typeof(abc1) == typeof(abc2)).stringof);
----------
C:\Users\Stewart\Documents\Programming\D\d2\tests>dmd -c const_static_array_3.d
immutable(char[26u])
const(immutable(char)[26u])
immutable(char[26u])
const(immutable(char)[26u])
true
true
false
----------
Again, the two should denote the exact same type, invariant(char[26u]). 
(immutable?  invariant?  See also issue 2572.)


-- 



More information about the Digitalmars-d-bugs mailing list