public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60978] New: [4.9 Regression] -Wenum-compare warns too eagerly
@ 2014-04-27 22:08 ppluzhnikov at google dot com
  2014-04-27 22:19 ` [Bug c++/60978] " ppluzhnikov at google dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: ppluzhnikov at google dot com @ 2014-04-27 22:08 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60978
           Summary: [4.9 Regression] -Wenum-compare warns too eagerly
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppluzhnikov at google dot com

Test case:

enum { A };
enum { B };

int foo(int x)
{
  return x ? A : B;
}

gcc -c -Wall t.c
# no warnings

g++ -c t.c
t.c: In function ‘int foo(int)’:
t.c:6:12: warning: enumeral mismatch in conditional expression: ‘<anonymous
enum>’ vs ‘<anonymous enum>’ [-Wenum-compare]
   return x ? A : B;
            ^

First, there is nothing to warn about here (in real code, I return IPPROTO_ICMP
or IPPROTO_ICMPV66 depending on address family).

Second, why is this pointing to the comparison and references enum-compare?
There is no comparison of unrelated enums here.
>From gcc-bugs-return-450009-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Apr 27 22:13:22 2014
Return-Path: <gcc-bugs-return-450009-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 16481 invoked by alias); 27 Apr 2014 22:13:22 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 16461 invoked by uid 48); 27 Apr 2014 22:13:18 -0000
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60978] [4.9 Regression] -Wenum-compare warns too eagerly
Date: Sun, 27 Apr 2014 22:13:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: pinskia at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-60978-4-2ubk0CKhSF@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60978-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60978-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-04/txt/msg02029.txt.bz2
Content-length: 342

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`978

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is documented to do this even in 4.8
(http://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/Warning-Options.html):
 In C++ enumeral mismatches in conditional expressions are also diagnosed and
the warning is enabled by default.


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

end of thread, other threads:[~2014-12-03  1:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-27 22:08 [Bug c++/60978] New: [4.9 Regression] -Wenum-compare warns too eagerly ppluzhnikov at google dot com
2014-04-27 22:19 ` [Bug c++/60978] " ppluzhnikov at google dot com
2014-04-27 22:51 ` manu at gcc dot gnu.org
2014-04-28 13:45 ` [Bug c++/60978] " ppluzhnikov at google dot com
2014-12-02 22:01 ` jason at gcc dot gnu.org
2014-12-02 22:23 ` jason at gcc dot gnu.org
2014-12-02 22:33 ` ppluzhnikov at google dot com
2014-12-03  1:29 ` paolo.carlini at oracle 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).