Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Future of C Date: Mon, 12 Mar 2018 18:29:02 -0700 Organization: None to speak of Lines: 43 Message-ID: References: <0231327b-9e28-46e4-9178-46c881a8dd91@googlegroups.com> <20180310180016.eda9bc36e1a3b182bc2563a8@gmail.com> <20180311000302.8e7cd15242a818ab75eb2e98@gmail.com> <83527acf-abed-4f8f-878c-7d4db9cd5ac1@googlegroups.com> <20180311161525.ac591de531b83d6b14b2cd43@gmail.com> <90236828-48d7-4ee5-9b86-4cedd0e29b5f@googlegroups.com> <3r7jne-t3h.ln1@gangtai.grep.be> <8e201938-ada4-42d9-8ae6-13b1047306e2@googlegroups.com> <69a08d82-b76a-4334-be63-20dc22f869bf@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="a9638e2b58572a27edc6516887e5eee0"; logging-data="22898"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mZ44rwX+waHFVHIxEcGUm" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:k6TEcUIGBHnLjT8o83uOtYo8Uwg= sha1:Ma5fltXbewZoYm4UvhXPfv+EdOs= Xref: csiph.com comp.lang.c:127729 supercat@casperkitty.com writes: [...] > Is there any way in which the following program would not be Strictly > Conforming: > > void test(size_t n) > { > int arr[n]; > arr[0] = 4; > arr[n-1] = 6; > } > int main(void) > { > test(-2); > } > > Conversion of the value -2 to a size_t has defined behavior, as would the > declaration of the array. On the other hand, one of the writes to arr[] > might very well clobber the stack even on a platform where guard pages > would normally ensure a shutdown in case of stack overflow. I suppose it's strictly conforming, but it's very likely to exceed a capacity limit at run time. void test(void) { #define N ((size_t)-2) int arr[N]; arr[0] = 4; arr[N-1] = 6; } int main(void) { test(); } I fail to see what fundamentally new problems were introduced by VLAs (when they were added to the language 19 years ago) that don't already exist for fixed-length arrays. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"