Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 36513
Product:  
Component:  
Status: ASSIGNED
Resolution:
Assigned To: Manuel López-Ibáñez <manu@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Benjamin Otte <otte@gnome.org>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
test.i Preprocessed source file text/plain 2009-11-25 10:26 2.46 KB Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 36513 depends on: Show dependency tree
Show dependency graph
Bug 36513 blocks:

Additional Comments:




Mark bug as waiting for feedback
Mark bug as suspended




View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2009-11-25 13:43 Opened: 2008-06-12 19:00
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.

------- Comment #1 From Andrew Pinski 2008-06-12 19:08 -------
Well also I think glibc should not need to optimise strchr really and let the
compiler do it.

------- Comment #2 From Manuel López-Ibáñez 2009-02-11 22:13 -------
We need a reproducible preprocessed testcase. 
See http://gcc.gnu.org/bugs.html#detailed

------- Comment #3 From Manuel López-Ibáñez 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.

------- Comment #4 From Benjamin Otte 2009-05-17 09:05 -------
I cannot reproduce this anymore with gcc 4.3.3 from Ubuntu 9.04, so I consider
this fixed.

------- Comment #5 From Manuel López-Ibáñez 2009-05-17 16:39 -------
FIXED per previous comment.

------- Comment #6 From Johan Gill 2009-11-25 10:02 -------
I get this error when building swfdec with gcc 4.4.2 on Fedora 12.

------- Comment #7 From Johan Gill 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.

------- Comment #8 From Johan Gill 2009-11-25 10:26 -------
Created an attachment (id=19148) [edit]
Preprocessed source file

Created a preprocessed source file producing the warning.

------- Comment #9 From Manuel López-Ibáñez 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.

------- Comment #10 From Manuel López-Ibáñez 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.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug