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

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).