Skip to content

std::is_trivially_copyable_v is false using clang for class with const class field. #59624

Open
@chriselrod

Description

https://godbolt.org/z/oEE5scYb8
^ Shows static_assert failure with clang, but not gcc or msvc. Code for reference:

#include <type_traits>
#include <utility>
#include <cstdint>
#include <cstddef>
struct Foo{
    size_t x{0};
};
struct CFoo{
    const size_t x{0};
};
struct Bar{
    const Foo y;
};

static_assert(std::is_trivially_copyable_v<Foo>); // pass
static_assert(std::is_trivially_copyable_v<CFoo>); // pass
static_assert(std::is_trivially_copyable_v<Bar>); // error for clang, pass for gcc

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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