https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90979
Bug ID: 90979 Summary: UBSan breaks OpenMP atomics Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org 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: --- The following testcase with -O2 -fopenmp -fsanitize=undefined,float-divide-by-zero actually doesn't end with the expected atomic operations: void foo (int *p, int x) { #pragma omp atomic *p = *p / x; } void bar (float *p, float x) { #pragma omp atomic *p = *p / x; } void baz (int *p, int x) { #pragma omp atomic *p <<= x; } void qux (int *p, int x) { #pragma omp atomic *p = *p >> x; } I bet we'll need to temporarily disable at least SANITIZE_SHIFT_BASE | SANITIZE_SHIFT_EXPONENT | SANITIZE_DIVIDE | SANITIZE_FLOAT_DIVIDE from flag_sanitize during the #pragma omp atomic parsing and then then readd that sanitization later or be able to pattern match what that sanitization creates later. Unfortunately, the first possibility would turn it off even for parsing of subexpressions.