Skip to content

Builtin type traits can't handle abominable function types as arguments #77585

@AMP999

Description

@AMP999

https://godbolt.org/z/9bb351bad

using RQ = int() &;
using CQ = int() const;

template<class T>
constexpr bool tc() { return __is_trivially_copyable(T); }
static_assert(!tc<RQ>()); // OK
static_assert(!tc<CQ>()); // OK

static_assert(!__is_trivially_copyable(RQ)); // Clang error
static_assert(!__is_trivially_copyable(CQ)); // Clang error

static_assert(!__is_trivially_copyable(int() &)); // EDG+Clang error
static_assert(!__is_trivially_copyable(int() const)); // EDG+Clang error

This parser limitation was clearly known when the tests for __has_unique_object_representations were added in https://reviews.llvm.org/D39064 , but it never explicitly came up during the code review. However, if we fixed the parser limitation, then we could simplify those tests to check the trait directly instead of going through @erichkeane's helper template in PR #77584.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions