Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Jul 2016 15:24:28 -0500
From:      Pedro Giffuni <pfg@FreeBSD.org>
To:        cem@freebsd.org, "Ngie Cooper (yaneurabeya)" <yaneurabeya@gmail.com>
Cc:        Dimitry Andric <dim@freebsd.org>, Roman Divacky <rdivacky@freebsd.org>, FreeBSD current <freebsd-current@freebsd.org>
Subject:   Re: clang 3.3/3.4 fails to build items that use stdlib.h because of __alloc_size attribute assigned to posix_memalign
Message-ID:  <3a288119-81f5-9199-b9d4-0f4649a7b8eb@FreeBSD.org>
In-Reply-To: <CAG6CVpXHK1J7vvR1LgFLs_fGyoZTTVw1Jput5xswKRSeYHEquw@mail.gmail.com>
References:  <838A69F7-343D-4398-928B-E54FB966B574@gmail.com> <CAG6CVpXHK1J7vvR1LgFLs_fGyoZTTVw1Jput5xswKRSeYHEquw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hmm ...

On 07/05/16 15:14, Conrad Meyer wrote:
> Whoops, missed reply-all the first time.
>
> It seems pretty clear that alloc_size (return value is a memory
> allocation of size from parameter N) does not apply to posix_memalign,
> because posix_memalign's allocation is stored via a pointer argument
> rather than return value.
>
> https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes
>
> IMO the attribute should be removed from posix_memalign in stdlib.h
>
> Best,
> Conrad
>

- I am wondering why it hasn't affected -current if it is wrong.
- I am also wondering if we shouldn't just get rid of the attribute.

I will answer to myself those doubts and fix the issue. Thanks!

Pedro.

> On Tue, Jul 5, 2016 at 1:07 PM, Ngie Cooper (yaneurabeya)
> <yaneurabeya@gmail.com> wrote:
>> Hi,
>>         It looks like clang 3.3/3.4 from ports both don’t like __alloc_size being attached to posix_memalign. This only concerns me because it might make the src upgrade path from 9.3/10.3 to 11.0 painful.
>>         Thoughts on how this should be fixed or whether or not we care?
>> Thanks,
>> -Ngie
>>
>> $ cd usr.sbin/bhyve; make clean; script ts make all CC=clang34
>> ...
>> In file included from /usr/src/svn/usr.sbin/bhyve/atkbdc.c:40:
>> /usr/include/stdlib.h:176:6: error: '__alloc_size__' attribute only applies to functions that return a pointer [-Werror,-Wignored-attributes]
>>             __alloc_size(3);                    /* (ADV) */
>>             ^
>> /usr/include/sys/cdefs.h:241:40: note: expanded from macro '__alloc_size'
>> #define __alloc_size(x) __attribute__((__alloc_size__(x)))
>>                                        ^
>> 1 error generated.
>> *** Error code 1
>>
>> Stop.
>> make: stopped in /usr/src/svn/usr.sbin/bhyve
>> $ (set -x; clang33 --version; clang34 --version)
>> + clang33 --version
>> clang version 3.3 (tags/RELEASE_33/final)
>> Target: x86_64-portbld-freebsd11.0
>> Thread model: posix
>> + clang34 --version
>> clang version 3.4.2 (tags/RELEASE_34/dot2-final)
>> Target: x86_64-portbld-freebsd11.0
>> Thread model: posix
>>
>> 282988        pfg int    posix_memalign(void **, size_t, size_t) __nonnull(1) __alloc_align(2)
>> 281130        pfg           __alloc_size(3);                    /* (ADV) */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3a288119-81f5-9199-b9d4-0f4649a7b8eb>