[llvm-bugs] [Bug 50719] New: clang++ wrong result on -O3 and above
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jun 15 08:59:09 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50719
Bug ID: 50719
Summary: clang++ wrong result on -O3 and above
Product: clang
Version: 12.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: shaohua.li at inf.ethz.ch
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Hi there,
I found that for a piece of code, clang++ would give out different results when
compiled with different opt flags.
$ clang++ -v
Ubuntu clang version
12.0.1-++20210605063018+0826268d59c6-1~exp1~20210605043737.99
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
$
$ clang++ -O0 a.cpp ; ./a.out
492559612348245.812500
$
$ clang++ -O3 a.cpp ; ./a.out
492559612348245.875000
$
$ cat a.cpp
#include <iostream>
#include <cstdint>
#include <iomanip>
#include <math.h>
#include <vector>
int main() {
std::vector<unsigned short> value = {19126};
double out = pow(2.0, value[0]/384.0-1.0);
std::cout << std::fixed << out << std::endl;
}
$
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210615/6e3381d7/attachment-0001.html>
More information about the llvm-bugs
mailing list