On Mon, 11 Nov 2002, David Malone wrote:

DM>On Mon, Nov 11, 2002 at 04:52:22PM +0100, Harti Brandt wrote:
DM>AG>But does using a union make it safe?
DM>
DM>> Well, I just had a long discussion with a collegue about the topic. The
DM>> main problem is in the ISO-C standard, section 6.7 point 4 which states:
DM>>
DM>> All declarations in the same scope that refer to the same object or
DM>> function shall specify compatible types.
DM>
DM>I think Section 6.5 paragraph 7 allows access through unions. There
DM>is a footnote saying that the list given (which includes access
DM>through the same type, qualified versions of the same type, aggregates
DM>and unions containign that type and character types) is intended
DM>for determining aliasing rules.

That just allows you to do

int     foo
union bar {
        int     foofoo;
} *ptr = (union bar)&foo;

I think. You end up with the same situation - you can refer the integer
object foo only through an integer pointer.

harti
-- 
harti brandt, http://www.fokus.gmd.de/research/cc/cats/employees/hartmut.brandt/private
              [EMAIL PROTECTED], [EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to