https://bugs.llvm.org/show_bug.cgi?id=47578
Bug ID: 47578
Summary: Incorrectly lift a modulo computation outside an if
statement
Product: clang
Version: 10.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: k.even-mend...@imperial.ac.uk
CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
neeil...@live.com, richard-l...@metafoo.co.uk
#include <stdio.h>
static long r = 0;
static long *m[1] = {&r};
static int i = 1;
static int *pi = &i;
int main() {
unsigned x = 0;
if (i) { // Evaluates to true
++x; // Guaranteed to be reached, and afterwards x == 1
int test = pi == (int*) 1;
}
printf("x = %d\n", x);
// At this point, x == 1
if (!x) { // Evaluates to false
i = 7UL % (m[0] == (long*) 1); // Unreachable. (It would have UB if it
*were* reachable, becuase of a mod by zero.)
}
}
Get "floating point exception" with -02, Ubuntun, and clang-6/Clang-10.
The bug is no appearing with -O0 flag.
Restor the bug:
clang-10 -O2 -w test1.c
./a.out
Floating point exception (core dumped)
======
clang-10 -O0 -w test1.c
./a.out
x = 1
I tried with two versions, both got the bugs:
1) from llvm trunk: clang version 10.0.0 (trunk), Target:
x86_64-unknown-linux-gnu, Thread model: posix, InstalledDir:
/home/user42/llvm-csmith-0/llvm-install/bin (from 03/09/2020)
2) Ubuntu's: clang version 10.0.0-4ubuntu1~18.04.2, Target:
x86_64-pc-linux-gnu, Thread model: posix, InstalledDir: /usr/bin
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs