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


Groups > comp.std.c > #1766

Re: What does it mean to evaluate a VLA?

From Shao Miller <sha0.miller@gmail.com>
Newsgroups comp.std.c
Subject Re: What does it mean to evaluate a VLA?
Date 2012-12-20 04:08 -0500
Organization A noiseless patient Spider
Message-ID <kaukj4$ftf$1@dont-email.me> (permalink)
References <lnr4mmrftq.fsf@nuthaus.mib.org> <kar7lo$5dk$1@dont-email.me> <kaujkm$av4$1@dont-email.me>

Show all headers | View raw


On 12/20/2012 03:52, Shao Miller wrote:
> On 12/18/2012 21:09, Shao Miller wrote:
>>
>> I would be startled if:
>>
>>    size_t sz = sizeof (func1(), (int[func2()]){0});
>>
>> didn't evaluate 'func1', which might influence the output of 'func2'.
>> (Untested.)
>>
>
> Erm, rather:
>
>    size_t sz = sizeof *(int(*)[(func1(), func2())]) 0;
>
> Oops.
>

Erm, that one has undefined behaviour for dereferencing a null pointer. 
  So rather:

   int foo[MORE_THAN_FUNC2_RETURNS];
   size_t sz = sizeof *(func1(), (int(*)[func2()]) &foo);

Sorry about that.  Hopefully the point about being "startled" is clear. :)

- Shao Miller

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


Thread

What does it mean to evaluate a VLA? Keith Thompson <kst-u@mib.org> - 2012-12-18 17:28 -0800
  Re: What does it mean to evaluate a VLA? Shao Miller <sha0.miller@gmail.com> - 2012-12-18 21:09 -0500
    Re: What does it mean to evaluate a VLA? Shao Miller <sha0.miller@gmail.com> - 2012-12-20 03:52 -0500
      Re: What does it mean to evaluate a VLA? Shao Miller <sha0.miller@gmail.com> - 2012-12-20 04:08 -0500
  Re: What does it mean to evaluate a VLA? Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-20 20:43 -0800
    Re: What does it mean to evaluate a VLA? Shao Miller <sha0.miller@gmail.com> - 2012-12-21 05:01 -0500
      Re: What does it mean to evaluate a VLA? Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-21 08:55 -0800

csiph-web