Bug 14780 – Non-intuitive behavior for pointers to aggregates defining opSlice

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-07-07T09:56:00Z
Last change time
2015-07-07T15:24:50Z
Assigned to
nobody
Creator
briancschott

Comments

Comment #0 by briancschott — 2015-07-07T09:56:52Z
``` struct HasOpSlice { int opSlice() { return 10; } } void main() { HasOpSlice* pointer; int i = pointer[]; } ``` test.d(9): Error: need upper and lower bound to slice pointer I'd like for this to Just Work(tm). I don't have any good ideas for how to make this behave consistently in the case that there's an opSlice that takes two arguments.
Comment #1 by ag0aep6g — 2015-07-07T14:36:41Z
Currently, operator overloads don't go through pointers. I.e., this isn't unique to opSlice. Only letting opSlice go through pointers would be silly, in my opinion. Doing it for all operators would be quite a change and should be well thought out.
Comment #2 by schveiguy — 2015-07-07T15:24:50Z
Yeah, this definitely isn't valid. You need a wrapper around the pointer to properly forward.