www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3005] New: ill-defined for statement

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3005

           Summary: ill-defined for statement
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: minor
          Priority: P5
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: andrei metalanguage.com


This compiles and runs:

void main() {
    int x = 2;
    for (while (false) x = 2; x != 2; ) {}
}

along with some other similarly odd constructs.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 17 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3005


BCS <shro8822 vandals.uidaho.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |shro8822 vandals.uidaho.edu




--- Comment #1 from BCS <shro8822 vandals.uidaho.edu>  2009-05-17 15:14:35 PDT
---
That's been known for some time. It's done that way to allow this to work:

for(int a = 5; a < 10; a++) {}
----[statment]

I think the best "fix" would be to switch from a statement, to allowing an
expression or declaration.

OTOH I'm fine with it as it is as it doesn't cause any known problems with
"reasonable" code.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 17 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3005


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|accepts-invalid             |spec




--- Comment #2 from Stewart Gordon <smjg iname.com>  2009-05-19 10:44:13 PDT ---
(In reply to comment #1)
 That's been known for some time. It's done that way to allow this to work:
 
 for(int a = 5; a < 10; a++) {}
 ----[statment]
 
 I think the best "fix" would be to switch from a statement, to allowing an
 expression or declaration.

That's how I thought it was defined - but it turns out ForStatement: for ( Initialize Test ; Increment ) ScopeStatement Initialize: ; NoScopeNonEmptyStatement so I was wrong about this being accepts-invalid. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 19 2009