This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [PATCH 05/11] A pointer to a pointer is nonnull.
- From: Peter Rosin <peda at lysator dot liu dot se>
- To: cygwin-patches at cygwin dot com
- Date: Mon, 21 Mar 2016 17:37:53 +0100
- Subject: Re: [PATCH 05/11] A pointer to a pointer is nonnull.
- Authentication-results: sourceware.org; auth=none
- References: <1458409557-13156-1-git-send-email-pefoley2 at pefoley dot com> <1458409557-13156-5-git-send-email-pefoley2 at pefoley dot com> <20160320111558 dot GG25241 at calimero dot vinschen dot de>
On 2016-03-20 12:15, Corinna Vinschen wrote:
> On Mar 19 13:45, Peter Foley wrote:
>> GCC 6.0+ can assert that this argument is nonnull.
>> Remove the unnecessary check to fix a warning.
>>
>> winsup/cygwin/ChangeLog
>> malloc_wrapper.cc (posix_memalign): Remove always true nonnull check.
>
> Eh, what?!? How on earth can gcc assert memptr is always non-NULL?
> An application can call posix_memalign(NULL, 4096, 4096) just fine,
> can't it? If so, *memptr = res crashes.
I think that passing NULL qualifies as undefined, in which case the
crash is ok, no?
I'm sure it will misbehave if you pass (void **)1 too. So, some might
argue that the business of special-casing NULL here is questionable.
Or is there some reason to protect the posix_memalign users from
themselves?
Cheers,
Peter