[LLVMbugs] [Bug 8399] New: Incorrect sizeof(long double) on Windows.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Oct 17 15:01:52 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=8399
Summary: Incorrect sizeof(long double) on Windows.
Product: clang
Version: trunk
Platform: PC
OS/Version: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: bigcheesegs at gmail.com
CC: llvmbugs at cs.uiuc.edu
The Microsoft C/C++ ABI treats long double as 8 bytes instead of the 12 that
others use. Clang doesn't know about this.
Also the MSVC code seems slightly better. Reusing st(0) instead of duplicating
it. But that's for another PR.
=============================================================================
file: long-double.c
=============================================================================
#include <stdio.h>
int main(void) {
long double x = 1.0;
printf("%Lf %Lf\n", x, x);
return sizeof(x);
}
=============================================================================
=============================================================================
compiler: clang
file: long-double.s
=============================================================================
.def _main;
.scl 2;
.type 32;
.endef
.text
.globl _main
.align 16, 0x90
_main: # @main
# BB#0: # %entry
pushl %ebp
movl %esp, %ebp
subl $32, %esp
fld1
fld %st(0)
fstpt 16(%esp)
fstpt 4(%esp)
movl $L_.str, (%esp)
calll _printf
movl $12, %eax
addl $32, %esp
popl %ebp
ret
.data
L_.str: # @.str
.asciz "%Lf %Lf\n"
.globl __fltused
=============================================================================
=============================================================================
compiler: cl.exe included with Visual C++ 2010
file: long-double.asm
=============================================================================
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.30319.01
TITLE
C:\Users\Michael\Projects\llvm\projects\test-suite\build\2008-01-07-LongDouble.c
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB LIBCMT
INCLUDELIB OLDNAMES
_DATA SEGMENT
$SG2686 DB '%Lf %Lf', 0aH, 00H
_DATA ENDS
PUBLIC __real at 3ff0000000000000
PUBLIC _main
EXTRN _printf:PROC
EXTRN __fltused:DWORD
; COMDAT __real at 3ff0000000000000
; File
c:\users\michael\projects\llvm\projects\test-suite\build\2008-01-07-longdouble.c
CONST SEGMENT
__real at 3ff0000000000000 DQ 03ff0000000000000r ; 1
; Function compile flags: /Ogtpy
CONST ENDS
_TEXT SEGMENT
_main PROC
; Line 4
fld1
sub esp, 16 ; 00000010H
fst QWORD PTR [esp+8]
fstp QWORD PTR [esp]
push OFFSET $SG2686
call _printf
add esp, 20 ; 00000014H
; Line 5
mov eax, 8
; Line 6
ret 0
_main ENDP
_TEXT ENDS
END
=============================================================================
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list