Skip to content

Clang++: Template specialization doesn't work with function attributes #65802

@gaaclarke

Description

@gaaclarke

Minimal reproduction

#include <type_traits>

#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))

VKAPI_ATTR void function1(int a, double b) {
  // ...
}

VKAPI_ATTR void function2(int a, double b) {
  // ...
}

template <typename T, typename U>
struct CheckSameSignature : std::false_type {};

template <typename Ret, typename... Args>
struct CheckSameSignature<Ret(Args...), Ret(Args...)> : std::true_type {};

static_assert(
    CheckSameSignature<decltype(function1), decltype(function2)>::value,
    "Functions have different signatures");

int main() { return 0; }

godbolt: https://godbolt.org/z/v5rafYo55

clang version

armv7-a clang 11.0.1

observed behavior

The static_assert fails saying the signatures are not the same.

expected behavior

I expect these signatures to be considered the same, just as they are if you remove the attributes.

error output

error: static_assert failed due to requirement 'CheckSameSignature<void (int, double) __attribute__((pcs("aapcs-vfp"))), void (int, double) __attribute__((pcs("aapcs-vfp")))>::value' "Functions have different signatures"armv7-a clang 11.0.1 #1

description

I'm not 100% sure this isn't some oddity with the c++ spec and not a failure to specialize correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions