Clang Ubsan negation and unsigned integer overflow warnings

Clang Ubsan negation and unsigned integer overflow warnings

  • As part of documenting the supported debugging/sanitizer builds, I've run them all through the paces with CI-Kit.
  • The Clang Ubsan builds reports several negation and unsigned integer overflow warnings.
  • These warnings are not necessarily bugs but may indicate reliance on implementation-specific, platform-specific, unspecified, or undefined behaviors.
  • These source lines correspond closely (but not exactly) with master as of today.
  • The full log (with warnings for third-party code and/or warnings already corrected) is available for context.
dps8_cpu.c:2238:22:  runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int'
dps8_cpu.c:2782:48:  runtime error: unsigned integer overflow: 134217726 * 125 cannot be represented in type 'unsigned int'

dps8_eis.c:10048:13: runtime error: negation of 1 cannot be represented in type 'word72' (aka 'unsigned __int128')
dps8_eis.c:8179:18:  runtime error: unsigned integer overflow: 10413 + 4294967295 cannot be represented in type 'unsigned int'
dps8_eis.c:8179:18:  runtime error: unsigned integer overflow: 3981 + 4294967295 cannot be represented in type 'unsigned int'
dps8_eis.c:9592:14:  runtime error: negation of 0xffffffffffffffffffffffffffffffff cannot be represented in type 'word72' (aka 'unsigned __int128')

dps8_ins.c:2090:9:   runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int'
dps8_ins.c:3869:24:  runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'uint' (aka 'unsigned int')
dps8_ins.c:4766:50:  runtime error: unsigned integer overflow: 0x00000000000000fffffffff800000000 * 0x00000000000000fffffffff800000000 cannot be represented in type 'unsigned __int128'
dps8_ins.c:4864:29:  runtime error: negation of 34359738368 cannot be represented in type 'word36' (aka 'unsigned long long')
dps8_ins.c:4997:20:  runtime error: negation of 960 cannot be represented in type 'word36' (aka 'unsigned long long')
dps8_ins.c:5033:21:  runtime error: negation of 33 cannot be represented in type 'word72' (aka 'unsigned __int128')

dps8_iom.c:2997:41:  runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int'

dps8_math.c:1101:9:  runtime error: negation of 0x00000000000000a20000000000000000 cannot be represented in type 'word72' (aka 'unsigned __int128')
dps8_math.c:2032:13: runtime error: negation of 0x000000000000001c71c71c71c71c7000 cannot be represented in type 'word72' (aka 'unsigned __int128')
dps8_math.c:2032:13: runtime error: negation of 0x00000000000000400000000000000000 cannot be represented in type 'word72' (aka 'unsigned __int128')
dps8_math.c:2032:13: runtime error: negation of 0x000000000000004ec000000000000000 cannot be represented in type 'word72' (aka 'unsigned __int128')
dps8_math.c:2032:13: runtime error: negation of 0x000000000000005b1f7df80000000000 cannot be represented in type 'word72' (aka 'unsigned __int128')
dps8_math.c:2386:7:  runtime error: left shift of negative value 0xffffffffffffffdecb66ca747ea07468
dps8_math.c:2386:7:  runtime error: left shift of negative value 0xfffffffffffffff00000000000000000
dps8_math.c:2931:24: runtime error: unsigned integer overflow: 0xffffffffffffffffffffffffffffffff + 1 cannot be represented in type 'unsigned __int128'
dps8_math.c:2963:24: runtime error: unsigned integer overflow: 0xffffffffffffffffffffffffffffffff + 1 cannot be represented in type 'unsigned __int128'
dps8_math.c:512:13:  runtime error: negation of 0x00000000000000400000000000000000 cannot be represented in type 'word72' (aka 'unsigned __int128')

dps8_utils.c:271:23: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned long long'
dps8_utils.c:271:23: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned long long'
dps8_utils.c:271:30: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned long long'
dps8_utils.c:429:23: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int'
dps8_utils.c:429:23: runtime error: unsigned integer overflow: 33 - 70 cannot be represented in type 'unsigned int'
dps8_utils.c:658:23: runtime error: unsigned integer overflow: 3923870461322648 - 3923870477048876 cannot be represented in type 'unsigned __int128'
dps8_utils.c:658:23: runtime error: unsigned integer overflow: 3923873167819675 - 3923873183545914 cannot be represented in type 'unsigned __int128'
dps8_utils.c:658:23: runtime error: unsigned integer overflow: 3923874112117060 - 3923874127843217 cannot be represented in type 'unsigned __int128'
dps8_utils.c:658:23: runtime error: unsigned integer overflow: 3923875080813605 - 3923875096539800 cannot be represented in type 'unsigned __int128'
dps8_utils.c:756:18: runtime error: negation of 1 cannot be represented in type 'word36' (aka 'unsigned long long')
dps8_utils.c:790:18: runtime error: negation of 688 cannot be represented in type 'word18' (aka 'unsigned int')
Edited by Jeffrey H. Johnson