https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81097
Bug ID: 81097
Summary: UBSAN: false positive for not existing negation
operator and a bogus message
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: sanitizer
Assignee: unassigned at gcc dot gnu.org
Reporter: babokin at gmail dot com
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at
gcc dot gnu.org
Target Milestone: ---
gcc rev249202.
Test case doesn't contain negations, but ubsan claims that negation has a
problem.
Error message also contains reference to '<unknown>' type. Though problems seem
to be related.
> cat f.cpp
unsigned int a = 3309568;
unsigned int b = -1204857327;
short c = -10871;
short x;
int main() {
x = (short(~a) | ~c) + (short(~b) | ~c);
return 0;
}
> g++ -fsanitize=undefined -O0 f.cpp -o out
> ./out
f.cpp:6:18: runtime error: negation of -32768 cannot be represented in type
'<unknown>'; cast to an unsigned type to negate this value to itself