Bug 5311 – Pure is broken when accessing globals / static data through instance reference

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-12-03T06:26:00Z
Last change time
2011-11-14T14:51:04Z
Keywords
accepts-invalid, patch
Assigned to
nobody
Creator
bruno.do.medeiros+deebugz

Comments

Comment #0 by bruno.do.medeiros+deebugz — 2010-12-03T06:26:17Z
See code below, there are two mutating accesses that should be error and are not: class X { private static int globalData; void breaksPure() pure const { //globalData++; // SHOULD BE ERROR //X.globalData++; // SHOULD BE ERROR this.globalData++; // SHOULD BE ERROR int a = this.globalData; // But readonly access is ok! } } static void breaksPure2(X x) pure { x.globalData++; // SHOULD BE ERROR int a = x.globalData; // But readonly access is ok! }
Comment #1 by k.hara.pg — 2011-11-10T22:24:54Z
Comment #2 by bugzilla — 2011-11-14T14:51:04Z