public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/45918] New: Lack of warning on meaningless unsigned to zero comparison
@ 2010-10-06 21:47 yuri at tsoft dot com
  2010-10-06 23:10 ` [Bug c++/45918] " paolo.carlini at oracle dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: yuri at tsoft dot com @ 2010-10-06 21:47 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Lack of warning on meaningless unsigned to zero
                    comparison
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: yuri@tsoft.com


In this case idx<NUM-1 is always false.
gcc should issue an error: comparison is always false due to the value range
limitations.

--- testcase ---
typedef unsigned size_t;

template<size_t NUM>
struct G {
  void fn();
};

template<size_t NUM>
void G<NUM>::fn() {
    for (size_t idx = 0; idx<NUM-1; idx++) {
    }
}

template struct G<1>;


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

end of thread, other threads:[~2011-03-29 17:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-06 21:47 [Bug c++/45918] New: Lack of warning on meaningless unsigned to zero comparison yuri at tsoft dot com
2010-10-06 23:10 ` [Bug c++/45918] " paolo.carlini at oracle dot com
2010-10-06 23:16 ` yuri at tsoft dot com
2010-10-06 23:18 ` paolo.carlini at oracle dot com
2010-10-07  0:45 ` manu at gcc dot gnu.org
2011-03-29 17:26 ` redi 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).