Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: double free Date: Mon, 11 Jul 2016 13:56:43 -0700 Organization: None to speak of Lines: 61 Message-ID: References: <577ba42f.13700328@news.xs4all.nl> <48c43c3f-8e7e-0509-5b9d-04133e7bb537@verizon.net> <57837892.8808984@news.xs4all.nl> <481f30b4-acb3-4445-92b3-c403dc3e51f7@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="26673"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19AP0IuRkaF0rAPejzjl3Xx" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:mpZlvmdXennK4l95A4zWxIEAAno= sha1:JRTXkRwBN4JsNkScmH7n3Un8NVY= Xref: csiph.com comp.lang.c:90233 BartC writes: > On 11/07/2016 18:53, Keith Thompson wrote: >> BartC writes: >>> The use of "*" here is unfortunate. But the way around it is to always >>> follow 'sizeof' with parentheses so that a following * can't be a multiply. >> >> sizeof is an operator, not a function. Always using parentheses makes >> it look like a function, which is misleading. > > And not using parentheses makes it look like a multiply. Which is worse? > > And Richard would say neither would be a problem if you see that it is > 'sizeof' and not any other identifier. > >>> Using "*" for dereference also gives rise to this: >>> >>> b * * * * p >> >> Which any sane C programmer would write as >> >> b * ***p > > I would use parentheses here as well. But the point is that some aspects > of C syntax are unusually sensitive to white space. So this probably > doesn't mean what it looks like at first: > > int* p,q,r; > > but this probably does: > > int *p,q,r; > > And this doesn't do what it looks like either: > > y = x**2; > > While this: > > y = x / *p; > > means something different from: > > y = x/*p; > > Like I said, the syntax was poorly thought out. All these examples > involve * used to do things with pointers. You've demonstrated that, by judicious misuse of white space, it's possible to write C code that's difficult to read. I hope you're not under the impression that this is news to anyone here. "Doctor, my code is hard to read when I do this!" ... -- 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"