[llvm-bugs] [Bug 44424] New: Simple C program produces different output if compiled with -O1 instead of -O0
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jan 1 06:43:16 PST 2020
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: unassignedclangbugs at nondot.org
Reporter: dirk.hoffmann at me.com
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
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200101/75b0462a/attachment.html>
More information about the llvm-bugs
mailing list