GNU bug report logs - #18711
Numerous unknown attribute '__alloc_size__' warnings when using clang

Previous Next

Package: guile;

Reported by: William S Fulton <wsf <at> fultondesigns.co.uk>

Date: Mon, 13 Oct 2014 20:58:02 UTC

Severity: normal

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

Forwarded to bdwgc@lists.opendylan.org

Full log


View this message in rfc822 format

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mark H Weaver <mhw <at> netris.org>
Cc: bdwgc <at> lists.opendylan.org, William S Fulton <wsf <at> fultondesigns.co.uk>, 18711 <at> debbugs.gnu.org
Subject: bug#18711: Numerous unknown attribute '__alloc_size__' warnings when using clang
Date: Tue, 14 Oct 2014 12:09:37 +0200
Mark H Weaver <mhw <at> netris.org> skribis:

> This is clearly an issue with bdwgc on clang, and possibly only on
> Apple's version of clang.  Here's the relevant section of
> gc/gc_config_macros.h from bdwgc 7.4.2:
>
> #ifndef GC_ATTR_ALLOC_SIZE
>   /* 'alloc_size' attribute improves __builtin_object_size correctness. */
>   /* Only single-argument form of 'alloc_size' attribute is used.       */
> # if defined(__GNUC__) && (__GNUC__ > 4 \
>         || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 && !defined(__ICC)) \
>         || __clang_major__ > 3 \
>         || (__clang_major__ == 3 && __clang_minor__ >= 2))
> #   define GC_ATTR_ALLOC_SIZE(argnum) __attribute__((__alloc_size__(argnum)))
> # else
> #   define GC_ATTR_ALLOC_SIZE(argnum)
> # endif
> #endif

AFAIK, Clang and ICC define __GNUC__ by default, even though they don’t
implement all the features of the corresponding GCC, which may explain
why the above doesn’t work as expected.

> You can see that the bdwgc developers have made an effort to check both
> GCC and clang version numbers before using the __alloc_size__ attribute.
> The code above seems to suggest that they believed clang 3.2 or later
> supported this attribute, whereas your version of clang seems to be
> based on upstream clang 3.5.  Perhaps Apple removed support for this
> attribute from their clang?

I think for Clang the right way would be to use the ‘__has_attribute’
magic macro:

  http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute

Ludo’.




This bug report was last modified 10 years and 277 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.