Thread overview
[Bug 20] New: volatile introduces new scope
Mar 06, 2006
d-bugmail
Mar 06, 2006
d-bugmail
Mar 06, 2006
Thomas Kuehne
Mar 21, 2006
d-bugmail
March 06, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=20

           Summary: volatile introduces new scope
           Product: D
           Version: 0.148
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: walter@digitalmars.com
        ReportedBy: thomas-dloop@kuehne.cn


void main(){
    int i = 1;
    volatile int i = 2; // should fail to compile
}

Testcases:
http://dstress.kuehne.cn/run/v/volatile_03_A.d
http://dstress.kuehne.cn/run/v/volatile_03_B.d
http://dstress.kuehne.cn/nocompile/v/volatile_03_C.d


-- 

March 06, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=20


smjg@iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com




------- Comment #1 from smjg@iname.com  2006-03-06 11:26 -------
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."


-- 

March 06, 2006
d-bugmail@puremagic.com 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


March 21, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=20


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #4 from bugzilla@digitalmars.com  2006-03-20 22:20 -------
Fixed 0.150


--