public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jason at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60978] -Wenum-compare warns too eagerly
Date: Tue, 02 Dec 2014 22:01:00 -0000	[thread overview]
Message-ID: <bug-60978-4-6105EYfu47@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60978-4@http.gcc.gnu.org/bugzilla/>

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |paolo.carlini at oracle dot com

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Manuel López-Ibáñez from comment #5)
> I think it should not warn for anonymous enums. The point of the warning is
> that using different enum types in a conditional expression is often some
> programming mistake. But in the case of anonymous enums, they are probably
> just used as named constants, so there is no much point in warning.

I don't think I agree.  Even with anonymous enums there is the risk that, as in
the reduced testcase here, you end up returning the same value by different
names.

You shouldn't get the warning about IPPROTO_ICMP vs IPPROTO_ICMPV66, as they
are members of the same anonymous enum.  If 4.9 started complaining, that's the
bug.
>From gcc-bugs-return-469263-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Dec 02 22:11:18 2014
Return-Path: <gcc-bugs-return-469263-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 24246 invoked by alias); 2 Dec 2014 22:11:17 -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 24191 invoked by uid 48); 2 Dec 2014 22:11:12 -0000
From: "ppluzhnikov at google dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60978] -Wenum-compare warns too eagerly
Date: Tue, 02 Dec 2014 22:11: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: diagnostic
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ppluzhnikov at google dot com
X-Bugzilla-Status: NEW
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-FZs6InXmof@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-12/txt/msg00270.txt.bz2
Content-length: 985

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

--- Comment #9 from Paul Pluzhnikov <ppluzhnikov at google dot com> ---
(In reply to Jason Merrill from comment #8)

> You shouldn't get the warning about IPPROTO_ICMP vs IPPROTO_ICMPV66, as they
> are members of the same anonymous enum.

They are?

In glibc-2.19, include/netinet/in.h:


/* Standard well-defined IP protocols.  */
enum
  {
    IPPROTO_IP = 0,       /* Dummy protocol for TCP.  */
#define IPPROTO_IP        IPPROTO_IP
    IPPROTO_ICMP = 1,       /* Internet Control Message Protocol.  */
#define IPPROTO_ICMP        IPPROTO_ICMP
...
};

/* If __USE_KERNEL_IPV6_DEFS is defined then the user has included the kernel
   network headers first and we should use those ABI-identical definitions
   instead of our own.  */
#ifndef __USE_KERNEL_IPV6_DEFS
enum
  {
    IPPROTO_HOPOPTS = 0,   /* IPv6 Hop-by-Hop options.  */
...
    IPPROTO_ICMPV6 = 58,   /* ICMPv6.  */
...
};


Looks like different anonymous enums to me.


  parent reply	other threads:[~2014-12-02 22:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-27 22:08 [Bug c++/60978] New: [4.9 Regression] " 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-60978-4-6105EYfu47@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).