Skip to content

Clang ignores visibility attribute of a template method of a template class #103477

Closed
@igorkudrin

Description

@igorkudrin

For the following source clang generates the symbol _ZN1tIcE3barILi1EEEvv with the DEFAULT visibility:

template <class a>
struct t {
    template <int>
    static __attribute__((__visibility__("hidden")))
    void bar() {}
};

void test() {
    t<char>::bar<1>();
}
> clang -c test.cpp -target x86_64 -o test.o
> readelf -sW test.o
...
     5: 0000000000000000     6 FUNC    WEAK   DEFAULT     5 _ZN1tIcE3barILi1EEEvv

gcc for the same case generates a HIDDEN symbol: https://godbolt.org/z/9z7soKfoa

The problem may be similar to #31462, but there are no explicit instantiations with different visibility attributes here. Applying D153835 or D154774 fixes this issue, but these revisions seem to be abandoned. #72092 does not resolve it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions