Skip to content

Clang++ crashes when instantiating a particular template class with a static constexpr data member. #165988

@cassioneri

Description

@cassioneri

This code makes clang++ to crash:

template <typename>
struct S {
  static constexpr char c{};
  static constexpr decltype(&c) p = nullptr;
};

auto f() {
  return S<int>::p;
}

GCC and MSVC have no issue to compile the code.

https://godbolt.org/z/edr4h4v99

If instead of being deduced, the type of S::p or the return type of f is explicitly given (const char*), then compilation succeeds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.crashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions