https://bugs.llvm.org/show_bug.cgi?id=44424
Bug ID: 44424
Summary: Simple C program produces different output if compiled
with -O1 instead of -O0
Product: clang
Version: unspecified
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
Test program: main.cpp
#include <stdint.h>
#include <stdio.h>
bool foo(uint32_t x, uint32_t y)
{
uint32_t z = (uint16_t)x * (uint16_t)y;
return z & 0x80000000;
}
int main(int argc, char *argv[])
{
printf("%d\n", foo(0x7FFFF, 0x7FFFF));
}
Compiler:
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
Output:
> clang -O0 main.cpp; ./a.out
1
> clang -O1 main.cpp; ./a.out
0
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs