https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68816

            Bug ID: 68816
           Summary: gcc fails to detect pointer overflow leading to
                    undefined behaviour
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

extern void g( const char *);

void
f( const char * start, unsigned long ul)
{
    if (start + ul < start)
        g( start);
}

Here is cppcheck detecting the problem:

[dec4a.cc:15]: (warning) Invalid test for overflow 'start+ul<start'. Condition
is always false unless there is overflow, and overflow is Undefined Behaviour.

Reply via email to