Bug 20 – volatile introduces new scope

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2006-03-06T09:31:00Z
Last change time
2014-02-14T20:33:34Z
Assigned to
bugzilla
Creator
thomas-dloop

Comments

Comment #0 by thomas-dloop — 2006-03-06T09:31:12Z
Comment #1 by smjg — 2006-03-06T11:26:05Z
All runtime control statements of this kind introduce a scope. What bit of the spec states that volatile is any different? As I understand it: - volatile_03_A is correctly classified - volatile_03_B is incorrectly classified, because i is out of scope outside of the volatile statement - volatile_03_C is correctly classified, but for a different reason, namely "A local symbol's name, however, must be unique within the function."
Comment #2 by thomas-dloop — 2006-03-06T13:25:17Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-03-06: > All runtime control statements of this kind introduce a scope. What bit of the > spec states that volatile is any different? The current documentation states: # VolatileStatement: volatile Statement That is "Statement" instead of "BlockStatement" - thus not necessarily a new scope. Either I'm missing something - if you know, pleace quote - or the scoping of a few "*Statement"s looks fishy: # IfStatement: if ( IfCondition ) ThenStatement # IfStatement: if ( IfCondition ) ThenStatement else ElseStatement # ElseStatement: Statement # ThenStatement: Statement # if(true) # int i=2; # # assert(i == 2); // according to the docs: legal A quick search for "Statement" and "scope" didn't return any usefull hits. Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEDJlJ3w+/yD4P9tIRAtTTAKC2IvC45LJYuspT4aXRIGytNUtJegCfevFn 7qwwLMc6VYmeRLKl7GgbCSM= =0PXJ -----END PGP SIGNATURE-----
Comment #3 by smjg — 2006-03-07T05:32:47Z
As I understand it, a BlockStatement is just one way of introducing a new scope, and these runtime control statements are another. A consequence of this, along with a parsing ambiguity, has been mentioned before: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/1955 Personally, I think that a declaration as the Statement argument of a runtime control statement should be illegal. Meanwhile, what do you believe is the correct behaviour of this? void qwert(int yuiop) { if (yuiop != 0) int asdfg; static assert (!is(typeof(asdfg))); }
Comment #4 by bugzilla — 2006-03-20T22:20:55Z
Fixed 0.150