Skip to content

std::is_base_of should give correct result for incomplete unions #41188

@AlisdairM

Description

@AlisdairM
mannequin
Bugzilla Link 41843
Resolution FIXED
Resolved on Jun 17, 2019 08:45
Version 8.0
OS All
Attachments Source for failing test
CC @mclow,@zygoloid

Extended Description

C++20 clarifies the expectation for detecting traits that cannot determine a result due to an incomplete class. However, is_base_of is expected to recognize that unions can never have a base class, nor ever be a base class, and so give the correct result - per the current working draft.

The following code is expected to compile without triggering a static assert. For the current clang/libc++, it fails to compile the middle two heterogeneous assertions:

#include <type_traits>

struct Incomplete;
union Uncomplete;

int main() {
static_assert( std::is_base_of_v<Incomplete, Incomplete>);
static_assert(!std::is_base_of_v<Incomplete, Uncomplete>); // fails to compile
static_assert(!std::is_base_of_v<Uncomplete, Incomplete>); // fails to compile
static_assert(!std::is_base_of_v<Uncomplete, Uncomplete>);
}

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillalibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions