Address of union members
From: Ioannis Vranos (ivr_at_guesswh.at.grad.com)
Date: 06/30/04
- Next message: Newsgroup - Ann: "purify or code checking tools"
- Previous message: Dan Pop: "Re: Swapping"
- Next in thread: Andre Kostur: "Re: Address of union members"
- Reply: Andre Kostur: "Re: Address of union members"
- Reply: Denis Remezov: "Re: Address of union members"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 30 Jun 2004 20:17:11 +0300
In the union
union test { int i; int j; }a;
Is there any guarantee that a.i and a.j share the same memory address?
In the standard it is mentioned:
"The size of a union is sufficient to contain the largest of its data
members. Each data member is allocated as if it were the sole member
of a struct."
The key here is "sufficient to contain the largest of its data members"
which leaves the case open to be larger than the largest member, so for
example in an implementation it could be even:
sizeof(test)==2*sizeof(int);
Regards,
Ioannis Vranos
- Next message: Newsgroup - Ann: "purify or code checking tools"
- Previous message: Dan Pop: "Re: Swapping"
- Next in thread: Andre Kostur: "Re: Address of union members"
- Reply: Andre Kostur: "Re: Address of union members"
- Reply: Denis Remezov: "Re: Address of union members"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|