← Back to index
|
Original Bugzilla link
Bug 15351 – foreach by ref accepted, although front returns by value
Status
RESOLVED
Resolution
DUPLICATE
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-11-17T11:32:02Z
Last change time
2018-06-14T14:15:13Z
Assigned to
No Owner
Creator
Marc Schütz
Comments
Comment #0
by schuetzm — 2015-11-17T11:32:02Z
This compiles, but IMO shouldn't, because S.front doesn't return by ref: struct S { @property int front() { return 0; } @property bool empty() { return false; } void popFront() { } } void main() { foreach(ref i; S()) { } }
Comment #1
by alphaglosined — 2018-06-14T14:15:13Z
*** This issue has been marked as a duplicate of issue 11934 ***