This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C, C++] fundamental type object representation


> Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
> | Ian Lance Taylor <ian@airs.com> writes:
> | > 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).
> ...
> | 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.
>
> OK, thanks.  I was rewriting part of valarray and I saw I made that
> assumption, and since it is bug chasing time I thought I should make
> sure my use of memset() isn't going to bomb out.

- If of any help, the c4x's float format is: [exp:8|sign:1|fract:23]
  where the exponent is encoded in 2's complement form thereby:

  (float)0  :: [0|0|0] :: 1.0*2^0 :: 1.0

  and further defined that an exponent of -128 regardless of the value
  of it's sign and fraction fields is interpreted as 0.0, thereby:

  (int)0.0 :: (int)X*2^-128 :: may = (int)[-128|0|0] :: -2,147,483,648

  So if it's defined that non otherwise initialized static data fields
  are initialized to all zero's, then correspondingly such floats will be
  interpreted as being initialized to 1.0 as far as the c4x is concerned;
  which may or may not be ok, but possibly reasonable if simply known to
  the the case?



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]