https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88234
Bug ID: 88234 Summary: UBsan and runtime error: signed integer overflow using unsigned vector Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: noloader 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: --- I'm working on GCC135 from the compile farm. I'm experiencing a UBsan runtime error for signed overflow when using unsigned vectors. The algorithms in the real program depend on unsigned wrap; and not signed overflow. gcc135:~$ cat test.cxx #include <stdio.h> #include <altivec.h> #undef vector #undef pixel #undef bool typedef unsigned char byte; typedef __vector unsigned char uint8x16_p; typedef __vector unsigned int uint32x4_p; int main(int argc, char* argv[]) { uint32x4_p a = { 1795745381, 0, 0, 0 }; uint32x4_p b = { 1359893119, 0, 0, 0 }; uint32x4_p c = vec_add(a, b); byte x[16]; vec_vsx_st((uint8x16_p)c, 0, x); for (size_t i=0; i<16; ++i) printf("%02x ", x[i]); printf("\n"); return 0; } The data "1795745381" and "1359893119" were taken from the first finding at https://github.com/weidai11/cryptopp/issues/749. And: $ /opt/at12.0/bin/c++ -O1 -fsanitize=undefined -std=c++14 test.cxx -o test.exe gcc135:~$ ./test.exe test.cxx:15:25: runtime error: signed integer overflow: 1795745381 + 1359893119 cannot be represented in type 'int' e4 38 17 bc 00 00 00 00 00 00 00 00 00 00 00 00 Finally: gcc135:~$ /opt/at12.0/bin/c++ --version c++ (GCC) 8.2.1 20180813 (Advance-Toolchain-at12.0) [revision 263510] Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.