[src/binutils/dwarf.c:6459]: (warning) Invalid test for overflow 'start+ul<start'. Condition is always false unless there is overflow, and overflow is UB. if (start >= block_end || start + ul > block_end || start + ul < start)
Hmm, will this do the trick ? - if (start >= block_end || start + ul > block_end || start + ul < start) + if (start >= block_end || ul > (unsigned long) (block_end - start)) Cheers Nick
>will this do the trick ? It certainly seems to shut up cppcheck, the static analyser. Not sure how to get gcc or clang to detect this problem. $ cat dec4a.cc extern void g( const char *); void f( const char * start, unsigned long ul) { if (start + ul < start) g( start); } $ ~/gcc/results/bin/gcc -c -O2 -Wall -Wextra -Wtype-limits dec4a.cc $ ~/llvm/results/bin/clang++ -c -O2 -Wall dec4a.cc $
The master branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7460c0abe8a195243110e66624da095a44cc96d6 commit 7460c0abe8a195243110e66624da095a44cc96d6 Author: Nick Clifton <nickc@redhat.com> Date: Tue Dec 8 09:49:49 2015 +0000 Fix static analysis warning about undefined bheaviour. PR binutils/19310 * dwarf.c (display_debug_frames): Recode range test to avoid undefined behaviour.
Patch applied