Bug 1381 – Dereference operator still works with arrays and array types even though T[] -> T* is gone

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-07-27T09:49:00Z
Last change time
2014-02-16T15:23:37Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
jarrett.billingsley

Comments

Comment #0 by jarrett.billingsley — 2007-07-27T09:49:59Z
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.
Comment #1 by clugdbug — 2011-12-22T00:48:28Z
*** This issue has been marked as a duplicate of issue 3990 ***