public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/52283] New: "error: case label does not reduce to an integer constant" for constant folded cast expr
@ 2012-02-16 16:50 chrbr at gcc dot gnu.org
  2012-02-16 16:52 ` [Bug c/52283] " chrbr at gcc dot gnu.org
                   ` (25 more replies)
  0 siblings, 26 replies; 27+ messages in thread
From: chrbr at gcc dot gnu.org @ 2012-02-16 16:50 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52283
           Summary: "error: case label does not reduce to an integer
                    constant" for constant folded cast expr
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: chrbr@gcc.gnu.org


extern int u;

void b (int c)
{
  switch (c)
    {
    case (int) ( 2  | ( (4 < 8 ) ? 8 : u ) ) :
      break;
    }
}

fails with 
i.c:8:5: error: case label does not reduce to an integer constant

since GCC 4.6.2.

While is is legitimately a user error with respect to the standard, this brings
legacy issue for code that used to build with GCC 4.5. Note that GCC is usually
permissive with reduced integer constant use in case label, see PR39613. 

This change seems to have appeared with the removal of the lines in
c-common.c:check_case_value

  /* ??? Can we ever get nops here for a valid case value?  We
     shouldn't for C.  */
  STRIP_TYPE_NOPS (value);

so the check for INTEGER_CST now fails and fallthu into the error.


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

end of thread, other threads:[~2012-04-19  9:21 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-16 16:50 [Bug c/52283] New: "error: case label does not reduce to an integer constant" for constant folded cast expr chrbr at gcc dot gnu.org
2012-02-16 16:52 ` [Bug c/52283] " chrbr at gcc dot gnu.org
2012-02-16 17:11 ` jakub at gcc dot gnu.org
2012-02-16 17:17 ` joseph at codesourcery dot com
2012-02-16 17:56 ` manu at gcc dot gnu.org
2012-02-16 18:20 ` joseph at codesourcery dot com
2012-02-16 18:28 ` manu at gcc dot gnu.org
2012-02-16 19:03 ` jakub at gcc dot gnu.org
2012-02-16 21:02 ` manu at gcc dot gnu.org
2012-02-16 22:21 ` joseph at codesourcery dot com
2012-02-16 23:56 ` joseph at codesourcery dot com
2012-02-20 12:17 ` chrbr at gcc dot gnu.org
2012-02-20 15:41 ` chrbr at gcc dot gnu.org
2012-02-20 15:43 ` rguenth at gcc dot gnu.org
2012-02-20 16:46 ` manu at gcc dot gnu.org
2012-02-21  9:58 ` manu at gcc dot gnu.org
2012-02-21 17:51 ` joseph at codesourcery dot com
2012-02-21 17:54 ` manu at gcc dot gnu.org
2012-02-21 18:26 ` joseph at codesourcery dot com
2012-02-21 20:31 ` manu at gcc dot gnu.org
2012-02-21 20:37 ` manu at gcc dot gnu.org
2012-02-21 20:49 ` manu at gcc dot gnu.org
2012-02-23 15:09 ` chrbr at gcc dot gnu.org
2012-02-24  2:50 ` manu at gcc dot gnu.org
2012-02-27  8:30 ` chrbr at gcc dot gnu.org
2012-03-16 23:50 ` manu at gcc dot gnu.org
2012-04-19  9:21 ` chrbr at gcc dot gnu.org

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).