Bug 10281 – pure methods can use shared fields

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-06T04:23:00Z
Last change time
2013-11-21T04:30:14Z
Assigned to
nobody
Creator
Marco.Leise

Comments

Comment #0 by Marco.Leise — 2013-06-06T04:23:00Z
Pure doesn't consider shared variables accessed by other threads. In this sense m_fill is like a global variable even though local to the circular buffer struct and the implicit this parameter. struct SCircularBuffer { shared ℕ m_fill = 0; @property ℕ availableBytesForReading() const pure nothrow { return atomicLoad(m_fill); } }
Comment #1 by yebblies — 2013-11-21T04:30:14Z
And global variable can be read inside pure functions if they are accessible through a parameter.