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: Tue, 13 Mar 2018 14:26:55 -0700 Organization: None to speak of Lines: 39 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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="a9638e2b58572a27edc6516887e5eee0"; logging-data="17697"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+8HvEyRQj9W/lYkMzw8E6L" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:D1zdD6p84aLWuO/vGeU8oC4MGVk= sha1:8ts4rGpWHQiobTkQ/rAgjSGplBc= Xref: csiph.com comp.lang.c:127779 David Brown writes: > On 13/03/18 21:39, Keith Thompson wrote: >> David Brown writes: >> [...] > >>> I am sure there are plenty of details to take care of. And there are >>> some oddities with VLA's - if you write "int vs[foo()];", then when you >>> later write "int n = sizeof(vs);" you have to re-evaluate foo and might >>> give a result that is not actually the size of "vs". So you generate >>> the same code here as if the use had written "int n = 4 * foo();". >>> Again, this is not /hard/ because you have already done it. >> >> No, evaluating `sizeof vs` does *not* re-evaluate `foo()`. > > I'm looking at 6.5.3.4p2 here: > > The sizeof operator yields the size (in bytes) of its operand, which > may be an expression or the parenthesized name of a type. The size is > determined from the type of the operand. The result is an integer. If > the type of the operand is a variable length array type, the operand > is evaluated; otherwise, the operand is not evaluated and the result > is an integer constant. Yes. The type of a VLA object doesn't change after it's been created. 6.7.6.2p5: The size of each instance of a variable length array type does not change during its lifetime. The size or length of a VLA type has to be implicitly stored somewhere for sizeof to work correctly (unless optimization lets the value be determined at compile time). -- 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"