[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Review of sizeof usage

From: Branko Čibej <brane_at_wandisco.com>
Date: Sat, 15 Aug 2015 06:16:45 +0200

On 14.08.2015 01:25, Daniel Shahaf wrote:
> Branko Čibej wrote on Wed, Aug 12, 2015 at 10:07:49 +0200:
>> On 12.08.2015 00:31, Daniel Shahaf wrote:
>>>>> We have had problems with both styles in the past, so neither is immune
>>>>> to bugs. I prefer the explicit type as it is easier to grep.
>>>> The explicit type form is more accident-prone than the variable form
>>>> because any change requires two modifications in the same statement
>>>> instead of one.
>>> Why doesn't the compiler or buildbot catch accidents?
>> I can't imagine a way for the compiler to emit warnings for such
>> constructs without getting a far too large percentage of false
>> positives. It's perfectly valid, and in many cases required by some
>> object-like architecture, to allocate a buffer that has a different size
>> than the one implied by the pointer that stores the return value. This
>> is C, after all.
> Okay, so from the compiler authors' perspective, "allocation size mismatches
> pointed-to-object size" warnings should not be on by default. Fair enough.
> But from our perspective as Subversion maintainers, we never *intentionally*
> allocate a buffer smaller than the pointed-to object, so the warnings would be
> useful to us. We should therefore opt-in to them.

Smaller buffer, probably not. Larger, definitely.

-- Brane
Received on 2015-08-15 06:16:53 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.