Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c > #1857

Re: Unsequenced Side Effects on the Same Union

From Shao Miller <sha0.miller@gmail.com>
Newsgroups comp.std.c
Subject Re: Unsequenced Side Effects on the Same Union
Date 2013-01-18 15:07 -0500
Organization A noiseless patient Spider
Message-ID <kdca2j$m5n$1@dont-email.me> (permalink)
References (2 earlier) <50F6CF92.4090803@verizon.net> <kd745t$mm8$1@dont-email.me> <kfnfw1za4k2.fsf@x-alumni2.alumni.caltech.edu> <kd9v6r$ge3$1@dont-email.me> <kfntxqe8faa.fsf@x-alumni2.alumni.caltech.edu>

Show all headers | View raw


On 1/18/2013 14:25, Tim Rentsch wrote:
> Shao Miller <sha0.miller@gmail.com> writes:
>
>> On 1/17/2013 16:21, Tim Rentsch wrote:
>>> Furthermore it's easy to find an example where parts of a union
>>> can be modified separately in safety, eg,
>>>
>>>     union {
>>>       long  x[100];
>>>       short y[ sizeof (long[100]) / sizeof (short) ];
>>>     } u = {0};
>>>
>>>     u.x[10]++ * u.y[5]++;  /* assume sizeof (long) >= sizeof (short) */
>>>
>>> The scalar object u.x[10] is not the same scalar object as
>>> u.y[5], so this expression is safe.  (To be thorough, I should
>>> include a proviso that this code is run on a platform where
>>> all-bits-zero is the only representation of zero for both long
>>> and short, so the initialization produces object representation
>>> suitable for both members.)
>>>
>>
>> It can be (and has been) argued that this is a violation of 6.5p7.  In
>> fact, WG14 hasn't reached consensus.  (I asked.)
>
> Even supposing that were true, it's obviously irrelevant to the
> point I was making.  And besides, it's perfectly easy to
> construct an equivalent example that clearly doesn't run afoul of
> effective type limitations, simply by using character types.
>

Agreed.  I don't dispute "it's easy to find..." and I enjoyed your 
post's explanation of scalar accesses.  Thanks!

-- 
- Shao Miller
--
"Thank you for the kind words; those are the kind of words I like to hear.

Cheerily,"  -- Richard Harter

Back to comp.std.c | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Unsequenced Side Effects on the Same Union Shao Miller <sha0.miller@gmail.com> - 2013-01-15 22:32 -0500
  Re: Unsequenced Side Effects on the Same Union Nick Bowler <nbowler@draconx.ca> - 2013-01-16 14:55 +0000
    Re: Unsequenced Side Effects on the Same Union Shao Miller <sha0.miller@gmail.com> - 2013-01-16 10:53 -0500
    Re: Unsequenced Side Effects on the Same Union James Kuyper <jameskuyper@verizon.net> - 2013-01-16 11:04 -0500
      Re: Unsequenced Side Effects on the Same Union Nick Bowler <nbowler@draconx.ca> - 2013-01-16 20:56 +0000
        Re: Unsequenced Side Effects on the Same Union Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-17 13:21 -0800
          Re: Unsequenced Side Effects on the Same Union Shao Miller <sha0.miller@gmail.com> - 2013-01-17 17:50 -0500
            Re: Unsequenced Side Effects on the Same Union Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-18 11:25 -0800
              Re: Unsequenced Side Effects on the Same Union Shao Miller <sha0.miller@gmail.com> - 2013-01-18 15:07 -0500

csiph-web