public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/36513]  New: -Wlogical-op warns about strchr
@ 2008-06-12 19:01 otte at gnome dot org
  2008-06-12 19:09 ` [Bug c/36513] " pinskia at gcc dot gnu dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: otte at gnome dot org @ 2008-06-12 19:01 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

Compiling the following code with gcc-4.3 -Wlogical-op -O1

int main ()
{
  char *s, t;
  strchr (s, t);
}

leads to this warning:
test2.c: In function ‘main’:
test2.c:7: warning: logical ‘&&’ with non-zero constant will always evaluate as
true

This is because libc defines strchr to a macro in bits/string.h. It looks to me
like gcc should not warn about optimizations like __builtin_constant_p
optimizations as those are diectly targeted at being optimized out.


-- 
           Summary: -Wlogical-op warns about strchr
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: otte at gnome dot org


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


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

* [Bug c/36513] -Wlogical-op warns about strchr
  2008-06-12 19:01 [Bug c/36513] New: -Wlogical-op warns about strchr otte at gnome dot org
@ 2008-06-12 19:09 ` pinskia at gcc dot gnu dot org
  2009-02-11 22:13 ` [Bug target/36513] " manu at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-06-12 19:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-06-12 19:08 -------
Well also I think glibc should not need to optimise strchr really and let the
compiler do it.


-- 


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


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

* [Bug target/36513] -Wlogical-op warns about strchr
  2008-06-12 19:01 [Bug c/36513] New: -Wlogical-op warns about strchr otte at gnome dot org
  2008-06-12 19:09 ` [Bug c/36513] " pinskia at gcc dot gnu dot org
@ 2009-02-11 22:13 ` manu at gcc dot gnu dot org
  2009-05-15 20:13 ` manu at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-02-11 22:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from manu at gcc dot gnu dot org  2009-02-11 22:13 -------
We need a reproducible preprocessed testcase. 
See http://gcc.gnu.org/bugs.html#detailed


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org
             Status|UNCONFIRMED                 |WAITING


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


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

* [Bug target/36513] -Wlogical-op warns about strchr
  2008-06-12 19:01 [Bug c/36513] New: -Wlogical-op warns about strchr otte at gnome dot org
  2008-06-12 19:09 ` [Bug c/36513] " pinskia at gcc dot gnu dot org
  2009-02-11 22:13 ` [Bug target/36513] " manu at gcc dot gnu dot org
@ 2009-05-15 20:13 ` manu at gcc dot gnu dot org
  2009-05-17  9:06 ` otte at gnome dot org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-05-15 20:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from manu at gcc dot gnu dot org  2009-05-15 20:13 -------
Benjamin, note that -Wlogical-op will be enabled by -Wextra in GCC 4.5. 

I am willing to give it a try to fix this before 4.5 is released. However, I
cannot reproduce this problem, so please, provide a preprocessed testcase.


-- 


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


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

* [Bug target/36513] -Wlogical-op warns about strchr
  2008-06-12 19:01 [Bug c/36513] New: -Wlogical-op warns about strchr otte at gnome dot org
                   ` (2 preceding siblings ...)
  2009-05-15 20:13 ` manu at gcc dot gnu dot org
@ 2009-05-17  9:06 ` otte at gnome dot org
  2009-05-17 16:40 ` manu at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: otte at gnome dot org @ 2009-05-17  9:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from otte at gnome dot org  2009-05-17 09:05 -------
I cannot reproduce this anymore with gcc 4.3.3 from Ubuntu 9.04, so I consider
this fixed.


-- 


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


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

* [Bug target/36513] -Wlogical-op warns about strchr
  2008-06-12 19:01 [Bug c/36513] New: -Wlogical-op warns about strchr otte at gnome dot org
                   ` (3 preceding siblings ...)
  2009-05-17  9:06 ` otte at gnome dot org
@ 2009-05-17 16:40 ` manu at gcc dot gnu dot org
  2009-11-25 10:03 ` johan dot gill at gmail dot com
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-05-17 16:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from manu at gcc dot gnu dot org  2009-05-17 16:39 -------
FIXED per previous comment.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug target/36513] -Wlogical-op warns about strchr
  2008-06-12 19:01 [Bug c/36513] New: -Wlogical-op warns about strchr otte at gnome dot org
                   ` (4 preceding siblings ...)
  2009-05-17 16:40 ` manu at gcc dot gnu dot org
@ 2009-11-25 10:03 ` johan dot gill at gmail dot com
  2009-11-25 10:06 ` johan dot gill at gmail dot com
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: johan dot gill at gmail dot com @ 2009-11-25 10:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from johan dot gill at gmail dot com  2009-11-25 10:02 -------
I get this error when building swfdec with gcc 4.4.2 on Fedora 12.


-- 


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


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

* [Bug target/36513] -Wlogical-op warns about strchr
  2008-06-12 19:01 [Bug c/36513] New: -Wlogical-op warns about strchr otte at gnome dot org
                   ` (5 preceding siblings ...)
  2009-11-25 10:03 ` johan dot gill at gmail dot com
@ 2009-11-25 10:06 ` johan dot gill at gmail dot com
  2009-11-25 10:26 ` johan dot gill at gmail dot com
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: johan dot gill at gmail dot com @ 2009-11-25 10:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from johan dot gill at gmail dot com  2009-11-25 10:06 -------
Also tried the simple test case described in the bug description, although it
needs to add #include <string.h> at the top.

The warning is still there.


-- 


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


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

* [Bug target/36513] -Wlogical-op warns about strchr
  2008-06-12 19:01 [Bug c/36513] New: -Wlogical-op warns about strchr otte at gnome dot org
                   ` (6 preceding siblings ...)
  2009-11-25 10:06 ` johan dot gill at gmail dot com
@ 2009-11-25 10:26 ` johan dot gill at gmail dot com
  2009-11-25 13:43 ` manu at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: johan dot gill at gmail dot com @ 2009-11-25 10:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from johan dot gill at gmail dot com  2009-11-25 10:26 -------
Created an attachment (id=19148)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19148&action=view)
Preprocessed source file

Created a preprocessed source file producing the warning.


-- 


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


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

* [Bug target/36513] -Wlogical-op warns about strchr
  2008-06-12 19:01 [Bug c/36513] New: -Wlogical-op warns about strchr otte at gnome dot org
                   ` (8 preceding siblings ...)
  2009-11-25 13:43 ` manu at gcc dot gnu dot org
@ 2009-11-25 13:43 ` manu at gcc dot gnu dot org
  2010-02-19 21:22 ` manu at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-11-25 13:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from manu at gcc dot gnu dot org  2009-11-25 13:43 -------
Now that we have a preprocessed testcase, I will try to reduce it and add it to
the testsuite to avoid regressing here.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |manu at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-11-25 13:43:34
               date|                            |


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


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

* [Bug target/36513] -Wlogical-op warns about strchr
  2008-06-12 19:01 [Bug c/36513] New: -Wlogical-op warns about strchr otte at gnome dot org
                   ` (7 preceding siblings ...)
  2009-11-25 10:26 ` johan dot gill at gmail dot com
@ 2009-11-25 13:43 ` manu at gcc dot gnu dot org
  2009-11-25 13:43 ` manu at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-11-25 13:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from manu at gcc dot gnu dot org  2009-11-25 13:42 -------
(In reply to comment #6)
> I get this error when building swfdec with gcc 4.4.2 on Fedora 12.

It is a warning that you need to enable with -Wlogical-op explicitly.

I cannot reproduce the preprocessed testcase with GCC 4.5 rev 150311. If you
can reproduce it with a more recent revision, please let us know. Since this is
not a regression (it was a new warning in GCC 4.3), I don't think anyone will
try to fix it in GCC 4.3.x or GCC 4.4.x.

Now that we have a preprocessed testcase, I will try to reduce it and add it to
the testsuite to avoid regressing here.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|FIXED                       |


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


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

* [Bug target/36513] -Wlogical-op warns about strchr
  2008-06-12 19:01 [Bug c/36513] New: -Wlogical-op warns about strchr otte at gnome dot org
                   ` (9 preceding siblings ...)
  2009-11-25 13:43 ` manu at gcc dot gnu dot org
@ 2010-02-19 21:22 ` manu at gcc dot gnu dot org
  2010-02-19 21:25 ` manu at gcc dot gnu dot org
  2010-02-23 13:58 ` hjl dot tools at gmail dot com
  12 siblings, 0 replies; 14+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-02-19 21:22 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 628 bytes --]



------- Comment #11 from manu at gcc dot gnu dot org  2010-02-19 21:21 -------
Subject: Bug 36513

Author: manu
Date: Fri Feb 19 21:21:34 2010
New Revision: 156912

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156912
Log:
2010-02-19  Manuel López-Ibáñez  <manu@gcc.gnu.org>

        PR 36513
testsuite/
        * c-c++-common/pr36513.c: New testcase.
        * c-c++-common/pr36513-2.c: New testcase.

Added:
    trunk/gcc/testsuite/c-c++-common/pr36513-2.c
    trunk/gcc/testsuite/c-c++-common/pr36513.c
Modified:
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug target/36513] -Wlogical-op warns about strchr
  2008-06-12 19:01 [Bug c/36513] New: -Wlogical-op warns about strchr otte at gnome dot org
                   ` (10 preceding siblings ...)
  2010-02-19 21:22 ` manu at gcc dot gnu dot org
@ 2010-02-19 21:25 ` manu at gcc dot gnu dot org
  2010-02-23 13:58 ` hjl dot tools at gmail dot com
  12 siblings, 0 replies; 14+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-02-19 21:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from manu at gcc dot gnu dot org  2010-02-19 21:25 -------
FIXED in GCC 4.5


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug target/36513] -Wlogical-op warns about strchr
  2008-06-12 19:01 [Bug c/36513] New: -Wlogical-op warns about strchr otte at gnome dot org
                   ` (11 preceding siblings ...)
  2010-02-19 21:25 ` manu at gcc dot gnu dot org
@ 2010-02-23 13:58 ` hjl dot tools at gmail dot com
  12 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-02-23 13:58 UTC (permalink / raw)
  To: gcc-bugs



-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.5.0


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


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

end of thread, other threads:[~2010-02-23 13:58 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-12 19:01 [Bug c/36513] New: -Wlogical-op warns about strchr otte at gnome dot org
2008-06-12 19:09 ` [Bug c/36513] " pinskia at gcc dot gnu dot org
2009-02-11 22:13 ` [Bug target/36513] " manu at gcc dot gnu dot org
2009-05-15 20:13 ` manu at gcc dot gnu dot org
2009-05-17  9:06 ` otte at gnome dot org
2009-05-17 16:40 ` manu at gcc dot gnu dot org
2009-11-25 10:03 ` johan dot gill at gmail dot com
2009-11-25 10:06 ` johan dot gill at gmail dot com
2009-11-25 10:26 ` johan dot gill at gmail dot com
2009-11-25 13:43 ` manu at gcc dot gnu dot org
2009-11-25 13:43 ` manu at gcc dot gnu dot org
2010-02-19 21:22 ` manu at gcc dot gnu dot org
2010-02-19 21:25 ` manu at gcc dot gnu dot org
2010-02-23 13:58 ` hjl dot tools at gmail 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).