www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1381] New: Dereference operator still works with arrays and array types even though T[] -> T* is gone

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

           Summary: Dereference operator still works with arrays and array
                    types even though T[] -> T* is gone
           Product: D
           Version: 1.005
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: jarrett.billingsley gmail.com


I'm reporting this as 1.005 since I originally found this (and posted an
un-replied-to topic on the bugs NG) back in February.

Basically the implicit T[] -> T* conversion became illegal before 1.0 but some
bits of it probably still remain in the compiler.  First, you can dereference
an array to get the first element:

int[] a = [1, 2, 3];
writefln(*a); // writes 1

The other, more important problem, is that a naive "isPointerType" template
that uses "is(*T)" will actually return true for array types, even though
they're not pointer types.  

If this is intended behavior, I'm not sure what the purpose is, and it's
certainly not documented.


-- 
Jul 27 2007