Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: sizeof object got by dereferencing uniniitalized pointer Date: Fri, 29 Nov 2019 13:38:25 -0800 Organization: None to speak of Lines: 31 Message-ID: References: <21e377ab-2a49-4f7e-bc18-72f1cee63204@googlegroups.com> <9d5ee6d4-607b-405f-83d9-afbe2b073cac@googlegroups.com> <76a74489-4a1f-4561-a01b-b2962a10bae4@googlegroups.com> <2119c5dc-fc01-4a74-93f4-8027c7cc210e@googlegroups.com> <43093894-ed52-47de-85f4-eadd92a1499e@googlegroups.com> <877e3j52do.fsf@bsb.me.uk> <86eexr8qlh.fsf@linuxsc.com> <87v9r33211.fsf@bsb.me.uk> <861rtr8ndf.fsf@linuxsc.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="e0529dfbb494cbc11a767ed1ae1d9bb4"; logging-data="7765"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nJ1IhO1wHMMr8uPl6zqmA" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:p5xt+R7XV8ZOCCbK/WLFbYBIGCU= sha1:oQawmh6/F9IK4R7m6Cm2qIhjItY= Xref: csiph.com comp.lang.c:148302 Keith Thompson writes: > Richard Damon writes: [...] >> Yes, I agree that isn't what it SAYS, but it could be what they meant to >> say, but didn't word it right, for some of the reasons you mention. > [...] > > It's plausible that the rule *could* be that `sizeof vla_expression` > doesn't evaluate `vla_expression`, but I don't think it's plausible that > the committee didn't intend `vla_expression` to be evaluated (though > it's possible they didn't sufficiently think through what that means). Correction: Since there are cases (see below) where `sizeof vla_expression` actually has to evaluate `vla_expression` (or at least part of it) to determine the size, simply saying that it's not evaluated wouldn't work. [...] >> I think there may be a way >> to use a compound literal expression to create a new type in an >> expression, and then that type would need to be 'evaluated' > > Not directly, since the type name in a compound literal cannot be a VLA > type. But as Tim points out, it can be done by dereferencing a compound > literal of a pointer-to-VLA type. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */