Bug 64938 - sizeof(long double) should be 16 bytes, not 8
Summary: sizeof(long double) should be 16 bytes, not 8
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc   
(Show other bugs)
Version: 7.3
Hardware: alpha Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2002-05-14 22:00 UTC by Christopher Holmes
Modified: 2008-05-01 15:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-12-15 20:20:15 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

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:

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.

Note You need to log in before you can comment on or make changes to this bug.