public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gerald at pfeifer dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/65891] New: -Wlogical-op now warns about logical ‘and’ of equal expressions even when different types/sizeofs are involved
Date: Sat, 25 Apr 2015 20:18:00 -0000	[thread overview]
Message-ID: <bug-65891-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 65891
           Summary: -Wlogical-op now warns about logical ‘and’ of equal
                    expressions even when different types/sizeofs are
                    involved
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gerald at pfeifer dot com
                CC: polacek at redhat dot com
  Target Milestone: ---

Since 2015-04-21  Marek Polacek  <polacek@redhat.com>

    PR c/63357
    * c-common.c (warn_logical_operator): Warn if the operands have the
    same expressions.

we also diagnose code the following

  typedef int r_fun_t (int);

  r_fun_t * text_funcs[] = {0,0,0};

  int report (unsigned t)
  {
    typedef int s_fun_t (long, char);

    static s_fun_t * GUI_funcs[3];

    return (t < sizeof text_funcs / sizeof text_funcs[0] &&
            t < sizeof GUI_funcs / sizeof GUI_funcs[0]);
  }

with

  input: In function ‘report’:
  input:8:58: warning: logical ‘and’ of equal expressions [-Wlogical-op]
     return (t < sizeof text_funcs / sizeof text_funcs[0] &&
                                                          ^

when these two conditions are about two different types, defined in two
different locations, and the sizes are set differently.
>From gcc-bugs-return-484650-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Apr 25 20:23:03 2015
Return-Path: <gcc-bugs-return-484650-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 20673 invoked by alias); 25 Apr 2015 20:23:03 -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 20644 invoked by uid 48); 25 Apr 2015 20:22:59 -0000
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/65891]=?UTF-8?Q? -Wlogical-op now warns about logical ‘and’ of equal expressions even when different types?=/sizeofs are involved
Date: Sat, 25 Apr 2015 20:23: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: mpolacek at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 6.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc assigned_to target_milestone everconfirmed
Message-ID: <bug-65891-4-c9ZxiMzWJS@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65891-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65891-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: 2015-04/txt/msg02202.txt.bz2
Content-length: 720

https://gcc.gnu.org/bugzilla/show_bug.cgi?ide891

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2015-04-25
                 CC|                            |mpolacek at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |6.0
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Sorry.  I'll look into that.


             reply	other threads:[~2015-04-25 20:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-25 20:18 gerald at pfeifer dot com [this message]
2015-04-27 16:09 ` [Bug c/65891] " mpolacek at gcc dot gnu.org
2015-04-27 17:26 ` ktietz at gcc dot gnu.org
2022-01-03 20:10 ` [Bug c/65891] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
2022-01-21 13:54 ` rguenth at gcc dot gnu.org
2022-03-23 13:16 ` jlegg at feralinteractive dot com
2022-05-27  9:35 ` [Bug c/65891] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:31 ` jakub at gcc dot gnu.org
2023-07-07 10:30 ` [Bug c/65891] [11/12/13/14 " rguenth at gcc dot gnu.org

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-65891-4@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).