This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/68816] New: gcc fails to detect pointer overflow leading to undefined behaviour
- From: "dcb314 at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 09 Dec 2015 14:32:07 +0000
- Subject: [Bug c++/68816] New: gcc fails to detect pointer overflow leading to undefined behaviour
- Auto-submitted: auto-generated
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.