public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/61534] New: Wlogical-op should not warn when either operand comes from macro expansion
@ 2014-06-17 10:25 manu at gcc dot gnu.org
  2014-06-25 17:53 ` [Bug c/61534] " mpolacek at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: manu at gcc dot gnu.org @ 2014-06-17 10:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 61534
           Summary: Wlogical-op should not warn when either operand comes
                    from macro expansion
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: manu at gcc dot gnu.org

#define DEFINED (x != 0)

int foo(int x)
{
  if (!DEFINED && x != 0) return 0;
  return 1;
}

manuel@gcc10:~$ ~/test1/210581/build/gcc/cc1 -Wlogical-op test.c
 foo
test.c: In function ‘foo’:
test.c:5:16: warning: logical ‘and’ of mutually exclusive tests is always false
[-Wlogical-op]
   if (!DEFINED && x != 0) return 0;
                ^

Clang does not warn. This was the reason -Wlogical-op was moved out of -Wextra
(PR40172).
>From gcc-bugs-return-454370-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jun 17 10:33:59 2014
Return-Path: <gcc-bugs-return-454370-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 25269 invoked by alias); 17 Jun 2014 10:33:58 -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 25226 invoked by uid 48); 17 Jun 2014 10:33:55 -0000
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/60759] improve -Wlogical-op
Date: Tue, 17 Jun 2014 10:33: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: 4.6.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: manu at gcc dot gnu.org
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: bug_status cf_reconfirmed_on short_desc everconfirmed
Message-ID: <bug-60759-4-dOycqSgqww@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60759-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60759-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-06/txt/msg01452.txt.bz2
Content-length: 1403

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-06-17
            Summary|-Wlogical-op should perhaps |improve -Wlogical-op
                   |warn about two-way implicit |
                   |conversions                 |
     Ever confirmed|0                           |1

--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
GCC's -Wlogical-op warns for this:

pr60759.c:6:12: warning: logical ‘or’ applied to non-boolean constant
[-Wlogical-op]
   return y || 3;
            ^

However, GCC does not warn when both operands are constants or neither is a
constant. I think it is clear that it should warn for the former case. The
conditions at which it should warn are the same (it warns even if the result is
used in a boolean context).

The latter case is more controversial. Moreover, in this case the context is
significant:

int a = foo(1) || foo(2);  // warn
bool a = foo(1) || foo(2);  // do NOT warn

Someone would need to check how much code will be wrongly warned and how to
minimize the amount of false positives.
>From gcc-bugs-return-454371-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jun 17 10:34:05 2014
Return-Path: <gcc-bugs-return-454371-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 25908 invoked by alias); 17 Jun 2014 10:34:05 -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 25547 invoked by uid 48); 17 Jun 2014 10:34:01 -0000
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/53131] -Wlogical-op: ready for prime time in -Wall ?
Date: Tue, 17 Jun 2014 10:34: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: 4.8.0
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: minor
X-Bugzilla-Who: manu 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-53131-4-DKPVR8kU9e@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-53131-4@http.gcc.gnu.org/bugzilla/>
References: <bug-53131-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-06/txt/msg01453.txt.bz2
Content-length: 582

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

--- Comment #8 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Manuel López-Ibáñez from comment #7)
> In fact, the main show-stopper for adding -Wlogical-op to -Wextra (or -Wall)
> is PR40172, which was the reason it was moved out of -Wextra in the first
> place. 

Since PR40172 was closed without fixing the real problem, I opened PR61534. As
far as I am aware, this is the only issue preventing -Wlogical-op to be moved
back to -Wextra. As always, patches welcome.
>From gcc-bugs-return-454372-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jun 17 10:55:05 2014
Return-Path: <gcc-bugs-return-454372-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 9948 invoked by alias); 17 Jun 2014 10:55:04 -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 9448 invoked by uid 48); 17 Jun 2014 10:54:32 -0000
From: "Ulrich.Windl at rz dot uni-regensburg.de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/61531] Optimizer completely removes some bitset code
Date: Tue, 17 Jun 2014 10:55: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: 4.3.4
X-Bugzilla-Keywords:
X-Bugzilla-Severity: major
X-Bugzilla-Who: Ulrich.Windl at rz dot uni-regensburg.de
X-Bugzilla-Status: WAITING
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-61531-4-4i23ewHEU2@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-61531-4@http.gcc.gnu.org/bugzilla/>
References: <bug-61531-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-06/txt/msg01454.txt.bz2
Content-length: 511

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

--- Comment #6 from Ulrich Windl <Ulrich.Windl at rz dot uni-regensburg.de> ---
(In reply to Richard Biener from comment #5)
> > rpm -q gcc43-c++
> gcc43-c++-4.3.4_20091019-0.22.17
> > rpm -q --changelog gcc43-c++ | head
> * Thu Nov 10 2011 rguenther@suse.com
> - Fix altivec comparison builtins.  [bnc#729378]

Could be SUSE-specific: Although I have all updates for the product installed,
my version is older (Fri Jan 09 2009, as indicated in comment #1).


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

end of thread, other threads:[~2024-01-24  1:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-17 10:25 [Bug c/61534] New: Wlogical-op should not warn when either operand comes from macro expansion manu at gcc dot gnu.org
2014-06-25 17:53 ` [Bug c/61534] " mpolacek at gcc dot gnu.org
2014-06-25 18:09 ` manu at gcc dot gnu.org
2014-06-25 18:21 ` mpolacek at gcc dot gnu.org
2014-11-02  0:57 ` manu at gcc dot gnu.org
2015-04-24 11:50 ` mpolacek at gcc dot gnu.org
2024-01-24  1:42 ` mpolacek 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).