Bug 64938

Summary: sizeof(long double) should be 16 bytes, not 8
Product: [Retired] Red Hat Linux Reporter: Christopher Holmes <cholmes>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3   
Target Milestone: ---   
Target Release: ---   
Hardware: alpha   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-12-15 20:20:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Christopher Holmes 2002-05-14 22:00:10 UTC
Description of Problem:

According to the IEEE standard:

  sizeof(float) = 4 bytes;
  sizeof(double) = 8 bytes;
  sizeof(long double) = 16 bytes;

The size of a long double is 8 bytes.

Version-Release number of selected component (if applicable):

gcc 2.96

How Reproducible:
always

Steps to Reproduce:
1. Compile the program a.C below: g++ -g -mieee a.C
2. ./a.out

Actual Results:

sizeof(long double) = 8

Expected Results:

sizeof(long double) = 16

Additional Information:

Expected results achieved on ia64-Linux platform.

Begin Program a.C:
#include <stdio.h>

int main(int argc, char *argv[])
{
  printf("sizeof(long double) = %d bytes\n",sizeof(long double));
  return 0;
}

End Program a.C

Comment 1 Jakub Jelinek 2002-05-17 09:43:34 UTC
IEEE 754 doesn't speak about C floating types, it just defines a single
precision, double precision and quad precision data format (and IEEE 854
adds double extended precision).
How this maps onto C types is the matter of the various architecture ABIs.
You cite above IA-64, but although sizeof (long double) is 16 on IA-64, it is
actually not the quad precision IEEE 754 data format, but IEEE 854 double extended.
IA-32 uses double extended precision long double too, though sizeof (long double)
is there 12.
Most architectures use double precision for double and long double, some
(like 64-bit SPARC and in the not too distant future 32-bit SPARC and PPC too)
use quad precision for long double.