Path: csiph.com!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail From: =?UTF-8?B?SGFucy1CZXJuaGFyZCBCcsO2a2Vy?= Newsgroups: comp.std.c Subject: Re: Initial draft proposal: "Safe arrays and pointers for C" Date: Tue, 14 Aug 2012 21:09:12 +0200 Lines: 33 Message-ID: References: <502949DA.9000604@animats.com> <50297066.1010202@loria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.dfncis.de t4vDbWoDuNF7lh+R0DcuPgBYTKBtZmf//1MeaSs6cW8YV1w6a3z/QQOuXNlgk/pGqcJO5JiCmu Cancel-Lock: sha1:QrUfH4fuw9/+N8r/Z4lG9tpDqUk= User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:13.0) Gecko/20120604 Thunderbird/13.0 In-Reply-To: Xref: csiph.com comp.std.c:1433 On 14.08.2012 20:20, John Nagle wrote: > On 8/13/2012 10:23 PM, Keith Thompson wrote: >> C does not have parameters of array type. "a" is not an array, it's a >> pointer. > compatible types." This would seem to imply that implementations > should (or at least could) check VLA size match at function calls. No, they shouldn't, because, as Keith just told you above, there is no such thing as "a VLA ... at function calls". No other non-VL array, either, for that matter. A function argument simply is _never_ an array. > sizeof(a) is the size of a pointer, here 4. That's questionable. No, it's not. That's what C has been doing since the dawn of time. sizeof(a) yields the size of a pointer for the least questionable reason there could be: because 'a' _is_ a pointer. > It's questionable because sizeof results for a local VLA are > different. No it's not, because that 'a' is not a VLA at all, so the argument doesn't apply to it. > Is this intentional, a GCC bug, or an ambiguity in the standard? The former. > It's certainly desirable to be able to obtain the size of an array > when the language knows it. But in the case at hand the language _doesn't_ know it.