Skip to content

Different results for 'clang++ huh.cpp' and 'clang++ -O3 huh.cpp' - Codegen?? #11747

@llvmbot

Description

@llvmbot
Bugzilla Link 11375
Resolution FIXED
Resolved on Nov 17, 2011 22:25
Version trunk
OS MacOS X
Blocks llvm/llvm-bugzilla-archive#11388
Attachments Sample program demonstrating the bug
Reporter LLVM Bugzilla Contributor
CC @atrick,@DougGregor,@efriedma-quic

Extended Description

When compiling the attached code (huh.cpp), I get different results when specifying -O3 vs. -O0

$ clang++ -O0 huh.cpp && ./a.out

Test fail on line 111 1 == 0

Returning: 5, 14
Returning: 5, 14
Returning: 5, 14
Returning: 7, 7
Returning: 7, 11
Returning: 5, 15
Returning: 5, 15
Returning: 5, 15
Returning: 9, 9
Returning: 9, 12

$ clang++ -O3 huh.cpp && ./a.out

Test fail on line 111 1 == 0

Returning: 5, 12
Returning: 7, 14
Returning: 5, 14
Returning: 7, 7
Returning: 7, 11
Returning: 5, 15
Returning: 5, 15
Returning: 5, 15
Returning: 9, 9
Returning: 9, 12

The first two lines are different!!
gcc gets the same results as -O0 (which I believe is correct).

Platform is x86, Darwin (Mac OS X 10.7.2)
Occurs on:

$ clang++ --version
clang version 3.1 (trunk 144534)
Target: x86_64-apple-darwin11.2.0
Thread model: posix

-- and --

$ clang++ --version
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.2.0
Thread model: posix

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillac++

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions