This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/68816] New: gcc fails to detect pointer overflow leading to undefined behaviour


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]