Bug 11047 – UDA + getAttributes bypass purity/safety check

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-15T13:59:00Z
Last change time
2016-10-01T11:47:41Z
Keywords
accepts-invalid, pull, safe
Assigned to
nobody
Creator
maxim
See also
https://issues.dlang.org/show_bug.cgi?id=13442

Comments

Comment #0 by maxim — 2013-09-15T13:59:24Z
Code from February thread: http://www.digitalmars.com/d/archives/digitalmars/D/Possible_UDA_bug_190800.html import std.stdio; int x; @(write(x++),writeln()) void foo(){} @safe pure void main(){ __traits(getAttributes, foo); __traits(getAttributes, foo)[0]; __traits(getAttributes, foo)[0]; //write(x++), writeln(); // Error: ... } By the way, irrespective of attributes, the issue raised in the thread regarding validity of code above should be at least documented (or code rejected if considered to be a bug).
Comment #1 by bugzilla — 2016-06-13T02:08:33Z
http://dlang.org/spec/attribute.html#UserDefinedAttribute They are defined as "compile time expressions" meaning they have to be evaluatable at compile time into a manifest constant. The bug here is this is not being checked.
Comment #2 by bugzilla — 2016-06-13T02:28:37Z
Comment #3 by github-bugzilla — 2016-06-16T23:22:19Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/55bd78ded94a1f40ee80c4e42791f216e5d58c41 fix Issue 11047 - UDA + getAttributes bypass purity/safety check https://github.com/dlang/dmd/commit/d1c3b6a1eab3347d9b6eb832b99ee45f70bd3702 Merge pull request #5863 from WalterBright/fix11047 fix Issue 11047 - UDA + getAttributes bypass purity/safety check
Comment #4 by github-bugzilla — 2016-10-01T11:47:41Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/55bd78ded94a1f40ee80c4e42791f216e5d58c41 fix Issue 11047 - UDA + getAttributes bypass purity/safety check https://github.com/dlang/dmd/commit/d1c3b6a1eab3347d9b6eb832b99ee45f70bd3702 Merge pull request #5863 from WalterBright/fix11047