Article View: comp.std.c
Article #4166Union access
From: Ian Cargill
Date: Tue, 03 Oct 1995 16:13
Date: Tue, 03 Oct 1995 16:13
22 lines
1256 bytes
1256 bytes
It has been asserted elsewhere by someone that:
> "The only guarantee that C gives is that the following data
> structure can be written one way and read another."
>
> union {
> unsigned char a[4];
> int b;
> }
I replied with my opinion that this is actually implementation defined
behavior, and that the only guarantee the standard gives is regarding
access to common initial sequences of structs in a union.
Since there is still some dispute, I would welcome comment from the
assembled multitude, particularly those who know what they are talking
about. A majority verdict will do. :-)
--
============================================================================
Ian Cargill CEng MIEE | Find out about the Association of C and C++ Users
Soliton Software Ltd. | info@accu.org OR http://www.accu.org/accu
Technical Details
Message-ID:
<812736828snz@soliton.demon.co.uk>Path:
arc1-ca.pugleaf.net!mail2news.demon.co.uk!soliton.demon.co.ukShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!soliton.demon.co.uk From: Ian Cargill <ian@soliton.demon.co.uk> Newsgroups: comp.std.c Subject: Union access Date: Tue, 03 Oct 95 16:13:48 GMT Organization: Soliton Software Ltd. Message-ID: <812736828snz@soliton.demon.co.uk> Reply-To: ian@soliton.demon.co.uk X-NNTP-Posting-Host: soliton.demon.co.uk X-Newsreader: Simple NEWS 2.0 (ka9q DIS 1.24)