This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [C, C++] fundamental type object representation
- From: Ian Lance Taylor <ian at airs dot com>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: 10 Dec 2005 19:09:11 -0800
- Subject: Re: [C, C++] fundamental type object representation
- References: <m3d5k45wl4.fsf@uniton.integrable-solutions.net>
Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
> Does GCC support any target where the object representation of a
> fundamental type T (e.g. int, float, double, pointers) whose all bits
> are zero does not hold value (T)0?
Surprisingly, the answer seems to be yes. For the C4X target, a
single precision floating point zero is apparently represented as
0x80000000 (for double precision there is another 32 zero bits).
That said, it doesn't actually work correctly. Compiling
float f;
float g = 0.0;
struct s { int i; float f; int j; };
struct s sv = { 1, 0.0, 2 };
gives me
.file "foo.c"
.version 40
.data
data_sec:
.global _g
.globl _g
.bss _g,1
.global _sv
.data
_sv:
.word 1
.word -2147483648
.word 2
.globl _f
.bss _f,1
.end
In other words, the floating point zero is only generated correctly
when gcc is forced to output the initializer for some other reason.
Given that doesn't work, it is probably reasonably safe to assume gcc
is always going to generate all zero bits for a fundamental types
initialized to zero.
Ian