public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49409] New: some possible new warnings for strange code
@ 2011-06-14 19:15 dcb314 at hotmail dot com
2011-06-14 22:34 ` [Bug c++/49409] " redi at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: dcb314 at hotmail dot com @ 2011-06-14 19:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49409
Summary: some possible new warnings for strange code
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: dcb314@hotmail.com
Consider the following code
extern void g( int);
void f( int i)
{
if (i == i) // same thing compared
g( i);
if (i != i) // same thing compared
g( 2 * i);
if ((i - i) > 10) // X - X == 0, unless volatile
g( 3 * i);
if (i || i) // duplicates in ||
g( 4 * i);
if (i && i) // duplicates in &&
g( 5 * i);
}
I ran the above code through the C++ compiler, with warning flags -Wall
-Wextra and it was surprisingly silent.
Would it be worthwhile for g++ to warn about some, all or none of
the above coding errors ?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/49409] some possible new warnings for strange code
2011-06-14 19:15 [Bug c++/49409] New: some possible new warnings for strange code dcb314 at hotmail dot com
@ 2011-06-14 22:34 ` redi at gcc dot gnu.org
2011-06-15 10:03 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2011-06-14 22:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49409
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-06-14 22:34:34 UTC ---
some warnings would seem sensible to me
I tried clang++ which only warns about the first two, via
-Wtautological-compare
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/49409] some possible new warnings for strange code
2011-06-14 19:15 [Bug c++/49409] New: some possible new warnings for strange code dcb314 at hotmail dot com
2011-06-14 22:34 ` [Bug c++/49409] " redi at gcc dot gnu.org
@ 2011-06-15 10:03 ` rguenth at gcc dot gnu.org
2015-08-12 14:58 ` paolo.carlini at oracle dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-06-15 10:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49409
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.06.15 10:03:26
Ever Confirmed|0 |1
--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-06-15 10:03:26 UTC ---
confirmed.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/49409] some possible new warnings for strange code
2011-06-14 19:15 [Bug c++/49409] New: some possible new warnings for strange code dcb314 at hotmail dot com
2011-06-14 22:34 ` [Bug c++/49409] " redi at gcc dot gnu.org
2011-06-15 10:03 ` rguenth at gcc dot gnu.org
@ 2015-08-12 14:58 ` paolo.carlini at oracle dot com
2015-08-12 15:03 ` mpolacek at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-08-12 14:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49409
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |polacek at redhat dot com
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Maybe Marek is interested (beyond -Wtautological-compare)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/49409] some possible new warnings for strange code
2011-06-14 19:15 [Bug c++/49409] New: some possible new warnings for strange code dcb314 at hotmail dot com
` (2 preceding siblings ...)
2015-08-12 14:58 ` paolo.carlini at oracle dot com
@ 2015-08-12 15:03 ` mpolacek at gcc dot gnu.org
2015-08-12 17:42 ` paolo.carlini at oracle dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-08-12 15:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49409
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
With -Wall -Wlogical-op we warn for all the cases except "if ((i - i) > 10)"
and I'm not sure if we really want a warning for this case.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/49409] some possible new warnings for strange code
2011-06-14 19:15 [Bug c++/49409] New: some possible new warnings for strange code dcb314 at hotmail dot com
` (3 preceding siblings ...)
2015-08-12 15:03 ` mpolacek at gcc dot gnu.org
@ 2015-08-12 17:42 ` paolo.carlini at oracle dot com
2015-08-12 18:08 ` mpolacek at gcc dot gnu.org
2015-08-12 18:10 ` mpolacek at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-08-12 17:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49409
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |jsm28 at gcc dot gnu.org
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Marek, could you please add to the audit trail which warnings work in which
version of GCC? Thanks in advance!
About the remaining case, I would be tempted to close the bug or maybe we could
first ask other maintainers...
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/49409] some possible new warnings for strange code
2011-06-14 19:15 [Bug c++/49409] New: some possible new warnings for strange code dcb314 at hotmail dot com
` (4 preceding siblings ...)
2015-08-12 17:42 ` paolo.carlini at oracle dot com
@ 2015-08-12 18:08 ` mpolacek at gcc dot gnu.org
2015-08-12 18:10 ` mpolacek at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-08-12 18:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49409
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
-Wtautological-compare has been added to GCC 6. -Wlogical-op is older, but the
part of it that warns about "i && i" is new and has only been added to GCC 6.
I agree about closing the bug now, BTW.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/49409] some possible new warnings for strange code
2011-06-14 19:15 [Bug c++/49409] New: some possible new warnings for strange code dcb314 at hotmail dot com
` (5 preceding siblings ...)
2015-08-12 18:08 ` mpolacek at gcc dot gnu.org
@ 2015-08-12 18:10 ` mpolacek at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-08-12 18:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49409
--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I meant "agree with closing".
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-08-12 18:10 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-14 19:15 [Bug c++/49409] New: some possible new warnings for strange code dcb314 at hotmail dot com
2011-06-14 22:34 ` [Bug c++/49409] " redi at gcc dot gnu.org
2011-06-15 10:03 ` rguenth at gcc dot gnu.org
2015-08-12 14:58 ` paolo.carlini at oracle dot com
2015-08-12 15:03 ` mpolacek at gcc dot gnu.org
2015-08-12 17:42 ` paolo.carlini at oracle dot com
2015-08-12 18:08 ` mpolacek at gcc dot gnu.org
2015-08-12 18:10 ` 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).