Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__is_trivial doesn't work in the presence of special member functions with trailing requires clauses #50084

Closed
ldionne opened this issue Jun 16, 2021 · 3 comments
Labels
bugzilla Issues migrated from bugzilla c++20 invalid Resolved as invalid, i.e. not a bug

Comments

@ldionne
Copy link
Member

ldionne commented Jun 16, 2021

Bugzilla Link 50740
Resolution INVALID
Resolved on Jun 16, 2021 12:09
Version trunk
OS All
CC @zygoloid

Extended Description

When compiled with Clang ToT, the following code incorrectly believes that allocator is non-trivial, when it should be trivial:

cat <<EOF | clang++ -xc++ - -std=c++2a -fsyntax-only
#include <type_traits>

template
struct allocator {
allocator() = default;
allocator() requires(!std::is_void_v) { }
};

static_assert(__is_trivial(allocator));

int main() { }
EOF

This works on GCC. Godbolt link: https://godbolt.org/z/4osMGWTne.

I tracked the issue down a bit, and I think the issue is that when QualType::isTrivialType() queries whether the class declaration has a non-trivial default constructor (via CXXRecordDecl::hasNonTrivialDefaultConstructor()), it incorrectly believes that it's the case.

@ldionne
Copy link
Member Author

ldionne commented Jun 16, 2021

I'm not a Clang expert, but I think CXXRecordDecl::addedMember() is incorrectly setting up this declaration:

allocator() requires(!std::is_void_v<T>) { } // where T = void

as a special member function that is non-trivial and user-provided, even though should (?) not be considered because of the trailing requires clause.

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Jun 16, 2021

This is part of P0848R3, which we don't yet implement.

@ldionne
Copy link
Member Author

ldionne commented Jun 16, 2021

Oh, thanks, I thought http://wg21.link/P0848 was just adding the trailing requires clauses to constructors with that use case in mind, but I had it wrong. So this is simply not implemented.

I guess we can close as INVALID, since this is not a bug, merely a missing feature.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++20 invalid Resolved as invalid, i.e. not a bug
Projects
None yet
Development

No branches or pull requests

1 participant