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


Groups > comp.lang.c > #76760

Re: sizeof on an uninitialized pointer to a VLA

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: sizeof on an uninitialized pointer to a VLA
Date 2015-11-21 12:46 +0000
Organization A noiseless patient Spider
Message-ID <87k2pbo6z6.fsf@bsb.me.uk> (permalink)
References (2 earlier) <ln610wevm8.fsf@kst-u.example.com> <87mvu8rbor.fsf@bsb.me.uk> <lnsi40axv9.fsf@kst-u.example.com> <871tbjpr4m.fsf@bsb.me.uk> <lnbnan8uf7.fsf@kst-u.example.com>

Show all headers | View raw


Keith Thompson <kst-u@mib.org> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>> Keith Thompson <kst-u@mib.org> writes:
> [...]
>>> I suggest something like:
>>>
>>>     If the operand is a parenthesized variable length array type name,
>>>     any expressions in the operand are evaluated.  Otherwise, the
>>>     operand is not evaluated.  The result is constant unless the
>>>     type of the operand is a variable length array type.
>>
>> I find the idea that the result of an expression might be anything but
>> constant rather odd.  Would "The result is *a* constant" be better?  But
>> then does the last sentence add anything very useful?  I'd be inclined
>> to omit it.
>
> Are you thinking that "constant" means "read-only"?  That's "const",
> which is not at all the same thing as "constant".
>
> The word "constant" means, basically, "evaluated at compile time".
> Specifically a constant expression is one that can be evaluated at
> compile time; the full definition is in N1570 6.6.

No, I'm thinking of the word used in the normal sense.  The result of
f()+1 is, to my mind, constant.  It is not const and it's not a constant
expression, but all three are different things.  6.6 defines constant
expressions, so that phrase would be better if that is what you
intended.

<snip>
> ...  A better formulation, I think, is:
>
>     If the operand is a parenthesized variable length array type name,
>     any expressions in the operand are evaluated.  Otherwise, the
>     operand is not evaluated.  The unary expression is an integer
>     constant expression unless the type of the operand is a variable
>     length array type.

Ah, yes, that's better in my opinion too.

<snip detail>
-- 
Ben.

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


Thread

sizeof on an uninitialized pointer to a VLA John Bode <jfbode1029@gmail.com> - 2015-11-19 11:39 -0800
  Re: sizeof on an uninitialized pointer to a VLA supercat@casperkitty.com - 2015-11-19 12:09 -0800
  Re: sizeof on an uninitialized pointer to a VLA "A. Bolmarcich" <aggedor@earl-grey.cloud9.net> - 2015-11-19 21:40 +0000
    Re: sizeof on an uninitialized pointer to a VLA supercat@casperkitty.com - 2015-11-19 13:50 -0800
  Re: sizeof on an uninitialized pointer to a VLA James Kuyper <jameskuyper@verizon.net> - 2015-11-19 17:50 -0500
    Re: sizeof on an uninitialized pointer to a VLA supercat@casperkitty.com - 2015-11-19 15:31 -0800
    Re: sizeof on an uninitialized pointer to a VLA Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-20 01:09 +0000
      Re: sizeof on an uninitialized pointer to a VLA supercat@casperkitty.com - 2015-11-19 19:10 -0800
    Re: sizeof on an uninitialized pointer to a VLA Keith Thompson <kst-u@mib.org> - 2015-11-20 03:52 -0800
      Re: sizeof on an uninitialized pointer to a VLA Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-20 14:24 +0000
        Re: sizeof on an uninitialized pointer to a VLA supercat@casperkitty.com - 2015-11-20 10:25 -0800
        Re: sizeof on an uninitialized pointer to a VLA Keith Thompson <kst-u@mib.org> - 2015-11-20 18:29 -0800
          Re: sizeof on an uninitialized pointer to a VLA Ian Collins <ian-news@hotmail.com> - 2015-11-21 16:35 +1300
            Re: sizeof on an uninitialized pointer to a VLA Keith Thompson <kst-u@mib.org> - 2015-11-20 20:24 -0800
              Re: sizeof on an uninitialized pointer to a VLA Ian Collins <ian-news@hotmail.com> - 2015-11-21 17:38 +1300
                Re: sizeof on an uninitialized pointer to a VLA Keith Thompson <kst-u@mib.org> - 2015-11-20 21:08 -0800
          Re: sizeof on an uninitialized pointer to a VLA Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-21 10:46 +0000
            Re: sizeof on an uninitialized pointer to a VLA Keith Thompson <kst-u@mib.org> - 2015-11-21 03:26 -0800
              Re: sizeof on an uninitialized pointer to a VLA Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-21 12:46 +0000
                Re: sizeof on an uninitialized pointer to a VLA Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-21 14:01 +0000
              Re: sizeof on an uninitialized pointer to a VLA supercat@casperkitty.com - 2015-11-21 09:02 -0800
                Re: sizeof on an uninitialized pointer to a VLA Keith Thompson <kst-u@mib.org> - 2015-11-21 12:09 -0800

csiph-web