Il 03/11/2012 16:26, Blue Swirl ha scritto:
>> > It's a clang bug.  The error should be suppressed, since the function is
>> > used with the weak alias.
>> >
>> > Or try if adding "|| defined __clang__" to compiler.h fixes it.
> It does.

Yeah, I tested now Clang/Linux myself and reported it as
http://llvm.org/bugs/show_bug.cgi?id=14250.  With a simple testcase such
as this:

static int g()
{
    return 42;
}
typeof(g) f __attribute__((__weak__, __alias__("g")));


it's easy to see that the function is actually emitted---and with "g" as
the name, even:

    .file    "g2.c"
    .text
    .align    16, 0x90
    .type    g,@function
g:                                      # @g
    .cfi_startproc
# BB#0:
    movl    $42, %eax
    ret
.Ltmp0:
    .size    g, .Ltmp0-g
    .cfi_endproc

    .weak    f
f = g
    .section    ".note.GNU-stack","",@progbits

> Maybe __APPLE__ should be replaced by __clang__, or can the
> problem also occur with GCC on Apple systems?

It can occur with GCC, though it will be just a "note" if I understand
correctly and not fail with -Werror.  No idea whether the generated code
would run, probably not.

My favorite fix is to just disable the warning, otherwise make the
function inline.

Paolo

Reply via email to