Thread overview
[Issue 3005] New: ill-defined for statement
May 17, 2009
BCS
May 19, 2009
Stewart Gordon
Jan 19, 2012
Walter Bright
May 17, 2009
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
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 19, 2009
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: -------
January 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3005


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |INVALID


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2012-01-19 12:20:43 PST ---
I'll mark it as invalid, then.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3005



--- Comment #4 from Andrei Alexandrescu <andrei@metalanguage.com> 2012-01-19 12:39:17 PST ---
Cool, this is going to make for some interesting plays :o).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------