public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/41388] New: -Wlogical-op produces a surprising message
@ 2009-09-17 11:52 Denis dot Excoffier at airbus dot com
2009-09-18 4:55 ` [Bug c/41388] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: Denis dot Excoffier at airbus dot com @ 2009-09-17 11:52 UTC (permalink / raw)
To: gcc-bugs
With the following C fragment, compiled with the option -Wlogical-op,
one obtains:
main.c:1006: warning: logical '&&' with non-zero constant will always evaluate
as true
This message is surprising because a non-zero constant does not
prevent any global '&&' expression to return either true or false,
depending on the other operands.
Instead, i could have expected the following messages:
main.c: In function 'main':
main.c:1000: warning: logical '&&' with zero constant will always evaluate as
false
main.c:1009: warning: logical '||' with non-zero constant will always evaluate
as true
This behavior is consistent through at least GCC 4.3.2 and GCC 4.4.1, and also
through Cygwin-1.7, Solaris2.8 and Solaris2.10 (checked 4 configurations).
Also in C++.
Fragment is:
-------------------------------------------------------------------
#include <stdio.h>
//
int main(/*unsigned*/ int const argc, char const *const *const argv) {
//
# line 1000
if (0 && (argc != 1) && (argc != 2) && 0) {
fprintf(stderr, "argc=%u\n", argc);
};
if (0 || (argc == 1) || (argc == 2) || 0) {
fprintf(stderr, "argc=%u\n", argc);
};
if (1 && (argc != 1) && (argc != 2) && 1) {
fprintf(stderr, "argc=%u\n", argc);
};
if (1 || (argc == 1) || (argc == 2) || 1) {
fprintf(stderr, "argc=%u\n", argc);
};
return(0);
}
-----------------------------------------------------
--
Summary: -Wlogical-op produces a surprising message
Product: gcc
Version: 4.4.1
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Denis dot Excoffier at airbus dot com
GCC build triplet: sparc-sun-solaris2.8
GCC host triplet: sparc-sun-solaris2.8
GCC target triplet: sparc-sun-solaris2.8
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41388
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/41388] -Wlogical-op produces a surprising message
2009-09-17 11:52 [Bug c/41388] New: -Wlogical-op produces a surprising message Denis dot Excoffier at airbus dot com
@ 2009-09-18 4:55 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-09-18 4:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2009-09-18 04:54 -------
Fixed in 4.5.0.
*** This bug has been marked as a duplicate of 36954 ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
Target Milestone|--- |4.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41388
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-09-18 4:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-17 11:52 [Bug c/41388] New: -Wlogical-op produces a surprising message Denis dot Excoffier at airbus dot com
2009-09-18 4:55 ` [Bug c/41388] " pinskia at gcc dot gnu dot 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).