After compiling and running my program with clang14
I found a bug in my program that boils down to the following code:
#include <iostream>
#include <limits>
int main() {
double a = std::numeric_limits<double>::max();
double b = -0.1;
double c = a * b - a * b;
std::cout << c << std::endl;
}
clang++-14 main.cpp -O2 && ./a.out
results in
-4.9896e+290
Why doesn't clang optimize code like this since version 14? Already at compile-time it turns out to be not zero.