public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/52655] New: right shit in switch: gcc compiles with error: label at end of compound statement
@ 2012-03-21 11:29 borut.razem at gmail dot com
  2012-03-21 11:34 ` [Bug c/52655] " mikpe at it dot uu.se
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: borut.razem at gmail dot com @ 2012-03-21 11:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52655

             Bug #: 52655
           Summary: right shit in switch: gcc compiles with error: label
                    at end of compound statement
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: borut.razem@gmail.com


The following code compiles with error: label at end of compound statement with
the gcc 4.6.1 compiler.

Content of t.c:
----8<----
void
foo (int op)
{
  int x = 100000 >> 3;  /* OK */

  switch (op)
    {
    case 0:
      x = 100000 >> 3;       /* t.c:12:5: error: label at end of compound
statement */
      break;

    default:
    }
}
---->8----

Command:
gcc -c t.c

Reproduced on OS version:
$ uname -srvmpo
Linux 2.6.32-5-686 #1 SMP Wed Jan 11 12:29:30 UTC 2012 i686 unknown GNU/Linux
and
Linux 3.0.0-16-generic #29-Ubuntu SMP Tue Feb 14 12:48:51 UTC 2012 x86_64
x86_64 GNU/Linux

Compiler version:
$ gcc --version
gcc (GCC) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

and
$ gcc --version
gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Borut


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/52655] right shit in switch: gcc compiles with error: label at end of compound statement
  2012-03-21 11:29 [Bug c/52655] New: right shit in switch: gcc compiles with error: label at end of compound statement borut.razem at gmail dot com
@ 2012-03-21 11:34 ` mikpe at it dot uu.se
  2012-03-21 12:06 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: mikpe at it dot uu.se @ 2012-03-21 11:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52655

--- Comment #1 from Mikael Pettersson <mikpe at it dot uu.se> 2012-03-21 11:29:40 UTC ---
(In reply to comment #0)
> The following code compiles with error: label at end of compound statement with
> the gcc 4.6.1 compiler.
> 
> Content of t.c:
> ----8<----
> void
> foo (int op)
> {
>   int x = 100000 >> 3;  /* OK */
> 
>   switch (op)
>     {
>     case 0:
>       x = 100000 >> 3;       /* t.c:12:5: error: label at end of compound
> statement */
>       break;
> 
>     default:

The "default:" acts as a label, and it needs a statement after it.  Just add
";" after it, or delete it.  The shift has nothing to do with this issue.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/52655] right shit in switch: gcc compiles with error: label at end of compound statement
  2012-03-21 11:29 [Bug c/52655] New: right shit in switch: gcc compiles with error: label at end of compound statement borut.razem at gmail dot com
  2012-03-21 11:34 ` [Bug c/52655] " mikpe at it dot uu.se
@ 2012-03-21 12:06 ` rguenth at gcc dot gnu.org
  2012-03-21 12:19 ` [Bug c/52655] confusing "error: label at end of compound statement" for default without statement manu at gcc dot gnu.org
  2012-03-21 12:56 ` borut.razem at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-21 12:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52655

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-03-21
     Ever Confirmed|0                           |1

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-21 11:53:26 UTC ---
Confirmed as weak diagnostic.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/52655] confusing "error: label at end of compound statement" for default without statement
  2012-03-21 11:29 [Bug c/52655] New: right shit in switch: gcc compiles with error: label at end of compound statement borut.razem at gmail dot com
  2012-03-21 11:34 ` [Bug c/52655] " mikpe at it dot uu.se
  2012-03-21 12:06 ` rguenth at gcc dot gnu.org
@ 2012-03-21 12:19 ` manu at gcc dot gnu.org
  2012-03-21 12:56 ` borut.razem at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: manu at gcc dot gnu.org @ 2012-03-21 12:19 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52655

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |manu at gcc dot gnu.org
         Resolution|                            |DUPLICATE
            Summary|right shit in switch: gcc   |confusing "error: label at
                   |compiles with error: label  |end of compound statement"
                   |at end of compound          |for default without
                   |statement                   |statement

--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-03-21 12:05:07 UTC ---
The location is correct (line 12, where the default is), but GCC doesn't have
caret info, so the user probably got confused.

Clang gives:

/tmp/webcompile/_24877_0.c:12:13: error: label at end of compound statement:
expected statement
    default:
            ^
1 error generated.

which is the same message and the same location but the caret clarifies
everything.

I really don't see how the diagnostics could be improved short of implementing
caret diagnostics, which is already opened in another PR24985.

*** This bug has been marked as a duplicate of bug 24985 ***


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/52655] confusing "error: label at end of compound statement" for default without statement
  2012-03-21 11:29 [Bug c/52655] New: right shit in switch: gcc compiles with error: label at end of compound statement borut.razem at gmail dot com
                   ` (2 preceding siblings ...)
  2012-03-21 12:19 ` [Bug c/52655] confusing "error: label at end of compound statement" for default without statement manu at gcc dot gnu.org
@ 2012-03-21 12:56 ` borut.razem at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: borut.razem at gmail dot com @ 2012-03-21 12:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52655

--- Comment #4 from Borut Ražem <borut.razem at gmail dot com> 2012-03-21 12:44:34 UTC ---
What a shame :-(
Sorry for the false alarm.

Borut


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-03-21 12:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-21 11:29 [Bug c/52655] New: right shit in switch: gcc compiles with error: label at end of compound statement borut.razem at gmail dot com
2012-03-21 11:34 ` [Bug c/52655] " mikpe at it dot uu.se
2012-03-21 12:06 ` rguenth at gcc dot gnu.org
2012-03-21 12:19 ` [Bug c/52655] confusing "error: label at end of compound statement" for default without statement manu at gcc dot gnu.org
2012-03-21 12:56 ` borut.razem at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).