LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 32 - C front-end miscompiles FP -> int initializers
Summary: C front-end miscompiles FP -> int initializers
Status: RESOLVED FIXED
Alias: None
Product: tools
Classification: Unclassified
Component: llvm-gcc (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Chris Lattner
URL:
Keywords: miscompilation
Depends on:
Blocks:
 
Reported: 2003-10-12 00:21 PDT by Chris Lattner
Modified: 2010-03-06 13:51 PST (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lattner 2003-10-12 00:21:08 PDT
In this testcase:

#include <stdio.h>
int main() {
  union { unsigned __l; float __d; } U = { 0x7fc00000U };
  printf("%f\n", U.__d);
}

The C front-end emits this:
...
        store float cast (uint 2143289344 to float), float* %tmp.1
...

which is obviously _very_ broken.
Comment 1 Chris Lattner 2003-10-12 02:24:29 PDT
It was ugly, and it required implementation in two places, but this is now fixed.

This is now tested here:
SingleSource/Regression/C/2003-10-12-GlobalVarInitializers.c