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


Groups > comp.lang.c > #2933

Re: multidimensional heap arrays

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: multidimensional heap arrays
Date 2011-04-26 14:39 -0700
Organization None to speak of
Message-ID <lny62wy9ns.fsf@nuthaus.mib.org> (permalink)
References (3 earlier) <4db663d9$0$4789$426a74cc@news.free.fr> <0.ba05a251a5fe8eed2ac7.20110426121957BST.8739l5dztu.fsf@bsb.me.uk> <91noctFq9bU7@mid.individual.net> <0.bece330a32ff7f1d21e3.20110426210623BST.87r58odbgg.fsf@bsb.me.uk> <91oq24Fq9bU9@mid.individual.net>

Show all headers | View raw


Ian Collins <ian-news@hotmail.com> writes:
> On 04/27/11 08:06 AM, Ben Bacarisse wrote:
>> Ian Collins<ian-news@hotmail.com>  writes:
>>
>>> On 04/26/11 11:19 PM, Ben Bacarisse wrote:
>>>> Francois Grieu<fgrieu@gmail.com>   writes:
>>>>
>>>>> On 26/04/2011 06:19, Anand Hariharan wrote:
>>>>
>>>>>> or will the 'arr' in the following code be a 'plain and ordinary'
>>>>>> array ...
>>>>>>
>>>>>> const int ncol = 5;
>>>>>> int arr[ncol];
>>>>
>>>> The former.  This is a VLA and will remain so in C1x.
>>>>
>>>>> I'm genuinely wondering: is ncol a "constant expression" ?
>>>>
>>>> It might be in that an implementation can define its own forms of
>>>> constant expression, but it does not meet the standard's minimum
>>>> requirements to be an "integer constant expression" (which is what is
>>>> required to declare a non-VL array).
>>>
>>> Which is really silly.  I do wish they could fix that and bring it in
>>> line with C++.  But I guess adding VLAs shot that idea in the foot.
>>
>> I too would like to have seen the same constant expression definition
>> between C++ and C but I don't see how C's VLAs got in the way of that.
>
> The code above sums it up, if ncol is an "integer constant expression" 
> is arr an array, or a VLA?
>
> Would it be acceptable for a language change to change (all be it 
> subtly) the behaviour of existing code?

What behavior would change?

Currently, arr is a VLA.  If the rules were changed to make ncol a
constant expression, as it is in C++, arr would be an ordinary array
object, not a VLA.  As far as I can tell, this would merely make some
things legal and well-defined that are currently either constraint
violations or undefined behavior.  I can't think of any cases were valid
code would either become invalid or change its (currently defined)
behavior.  Can you?

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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


Thread

multidimensional heap arrays Jack Boot <jackboot@mailinator.com> - 2011-04-25 19:36 +0000
  Re: multidimensional heap arrays Francois Grieu <fgrieu@gmail.com> - 2011-04-25 23:16 +0200
  Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-25 22:35 +0100
    Re: multidimensional heap arrays Anand Hariharan <mailto.anand.hariharan@gmail.com> - 2011-04-25 21:19 -0700
      Re: multidimensional heap arrays Francois Grieu <fgrieu@gmail.com> - 2011-04-26 08:19 +0200
        Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-26 12:19 +0100
          Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-26 23:25 +1200
            Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-26 21:06 +0100
              Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 08:59 +1200
                Re: multidimensional heap arrays Keith Thompson <kst-u@mib.org> - 2011-04-26 14:39 -0700
                Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 10:03 +1200
                Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-26 23:41 +0100
                Re: multidimensional heap arrays Keith Thompson <kst-u@mib.org> - 2011-04-26 16:33 -0700
                Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-27 04:05 +0100
                Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-26 22:49 +0100
                Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 10:19 +1200
                Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-27 00:38 +0100
                Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 11:48 +1200
                Re: multidimensional heap arrays Keith Thompson <kst-u@mib.org> - 2011-04-26 17:38 -0700
                Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 13:08 +1200
                Re: multidimensional heap arrays Tim Rentsch <txr@alumni.caltech.edu> - 2011-04-26 18:31 -0700
                Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 14:01 +1200
                Re: multidimensional heap arrays Tim Rentsch <txr@alumni.caltech.edu> - 2011-04-27 00:04 -0700
                Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 19:58 +1200
                Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 20:03 +1200
                Re: multidimensional heap arrays Keith Thompson <kst-u@mib.org> - 2011-04-27 00:03 -0700
                Re: multidimensional heap arrays Tim Rentsch <txr@alumni.caltech.edu> - 2011-04-26 18:20 -0700
                Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-27 03:59 +0100
                Re: multidimensional heap arrays Tim Rentsch <txr@alumni.caltech.edu> - 2011-04-27 00:24 -0700
    Re: multidimensional heap arrays "io_x" <a@b.c.invalid> - 2011-04-26 09:42 +0200
  Re: multidimensional heap arrays Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-04-25 20:50 -0400
  Re: multidimensional heap arrays James Kuyper <jameskuyper@verizon.net> - 2011-04-25 22:57 -0400

csiph-web