This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: designated initializers extension and sparc
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: Sergey Kljopov <hlodvig at unipro dot ru>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 17 Jun 2013 09:11:21 +0200
- Subject: Re: designated initializers extension and sparc
- References: <51BE3C28 dot 5070806 at unipro dot ru>
> I wrote the following test:
>
> union foo { int i; double d; };
>
> int main(int argc, char **argv)
> {
> union foo f = { .d = 4 };
>
> ASSERT_EQ(0, f.i);
> ASSERT_FEQ(4.0, f.d);
>
> return 0;
> }
>
> ASSERT_EQ and ASSERT_FEQ are some macros which checks the falue and
> gives some error messages.
>
> It seems that this extension should be bi-endian, however it fails on
> the sparc.
> What the problem with the test?
Type punning through union is actually the preferred way to expose endianness.
Ask yourself how the 'int' and the 'double' are laid out on the SPARC.
--
Eric Botcazou