Jump to page: 1 2
Thread overview
[Issue 6552] New: Wrong fallthrough warning for CaseRange
Aug 25, 2011
timon.gehr@gmx.ch
Apr 27, 2012
SomeDude
Apr 27, 2012
timon.gehr@gmx.ch
Apr 27, 2012
SomeDude
Feb 17, 2013
Andrej Mitrovic
Feb 18, 2013
Stewart Gordon
Feb 18, 2013
Andrej Mitrovic
Feb 18, 2013
Stewart Gordon
Feb 18, 2013
Kenji Hara
Feb 18, 2013
Andrej Mitrovic
August 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6552

           Summary: Wrong fallthrough warning for CaseRange
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: timon.gehr@gmx.ch


--- Comment #0 from timon.gehr@gmx.ch 2011-08-24 19:30:48 PDT ---
void main() {
    int c;
    switch (c) {
        case 1,2:
        case 3,4: break;
        default: break;
    }
}

Compile with warnings on, DMD v2.054:
tt.d(12): Error: switch case fallthrough - use 'goto case;' if intended

This warning is wrong.

For comparison, the equivalent code without CaseRanges passes even with warnings on:

void main() {
    int c;
    switch (c) {
        case 1:
        case 2: break;
        default: break;
    }
}

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


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com


--- Comment #1 from SomeDude <lovelydear@mailmetrash.com> 2012-04-27 09:58:55 PDT ---
Compiles on 2.059

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



--- Comment #2 from timon.gehr@gmx.ch 2012-04-27 10:29:09 PDT ---
No, it does not. Check again with the correct compiler options. (you need -w)

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



--- Comment #3 from SomeDude <lovelydear@mailmetrash.com> 2012-04-27 15:07:07 PDT ---
Allright, I overlooked your comment.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 17, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6552


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid
                 CC|                            |andrej.mitrovich@gmail.com
         AssignedTo|nobody@puremagic.com        |andrej.mitrovich@gmail.com


--- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-17 13:47:59 PST ---
https://github.com/D-Programming-Language/dmd/pull/1673

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6552


Stewart Gordon <smjg@iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|pull, rejects-valid         |accepts-invalid,
                   |                            |diagnostic, spec
                 CC|                            |smjg@iname.com


--- Comment #5 from Stewart Gordon <smjg@iname.com> 2013-02-17 17:33:51 PST ---
The code is not valid per the current spec.

http://dlang.org/statement.html#SwitchStatement

CaseStatement:
    case ArgumentList : ScopeStatementList

ScopeStatementList:
    StatementListNoCaseNoDefault

StatementListNoCaseNoDefault:
    StatementNoCaseNoDefault
    StatementNoCaseNoDefault StatementListNoCaseNoDefault

By this spec,
    case 1,2: case 3,4: anything
is invalid.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6552


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|accepts-invalid,            |pull, rejects-valid
                   |diagnostic, spec            |


--- Comment #6 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-17 17:43:36 PST ---
(In reply to comment #5)
> The code is not valid per the current spec.
> 
> http://dlang.org/statement.html#SwitchStatement
> 
> CaseStatement:
>     case ArgumentList : ScopeStatementList
> 
> ScopeStatementList:
>     StatementListNoCaseNoDefault
> 
> StatementListNoCaseNoDefault:
>     StatementNoCaseNoDefault
>     StatementNoCaseNoDefault StatementListNoCaseNoDefault
> 
> By this spec,
>     case 1,2: case 3,4: anything
> is invalid.

I already said the spec was wrong and will have to be fixed. The OP code works without -w, and we're not about to break a ton of code because the spec is outdated (which is *very* common).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6552



--- Comment #7 from Stewart Gordon <smjg@iname.com> 2013-02-17 18:07:37 PST ---
Where is the separate bug report about the spec being wrong?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6552



--- Comment #8 from Kenji Hara <k.hara.pg@gmail.com> 2013-02-17 18:29:26 PST ---
(In reply to comment #7)
> Where is the separate bug report about the spec being wrong?

Opened.
Issue 9529 - Switch Statement grammar bug for the chain of case statements

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6552



--- Comment #9 from github-bugzilla@puremagic.com 2013-02-17 19:34:01 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/cac04a3dd38741205cac6b61400a7f91a8c8a36a Fixes Issue 6552 - Invalid error on non-existent switch-case fallthrough.

https://github.com/D-Programming-Language/dmd/commit/631e980d134d7217ac3fe43809b625bc8f5bff9f Merge pull request #1673 from AndrejMitrovic/Fix6552

 Issue 6552 - Invalid warning on non-existent switch case fallthrough.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2