[Issue 1381] New: Dereference operator still works with arrays and array types even though T[] -> T* is gone
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jul 27 07:50:00 PDT 2007
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 at digitalmars.com
ReportedBy: jarrett.billingsley at 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.
--
More information about the Digitalmars-d-bugs
mailing list