Reputation: 6042
The following code
#include <cstdint>
#include <array>
#include <utility>
std::size_t constexpr num = 5;
using Doubles = std::array<double, num>;
struct meow {
template<typename V>
static constexpr V value(V v, std::size_t)
{
return v;
}
template<typename V, std::size_t... Indices>
static constexpr auto make(V v, std::index_sequence<Indices...>) -> std::array<V, sizeof...(Indices)>
{
return {{value(v, Indices)...}};
}
Doubles doubles = make(3.1415926535897932384626433, std::make_index_sequence<num>());
};
int main()
{
meow m;
return m.doubles.size();
}
is compiled by GCC in a sensible fashion, but clang tries to call meow::make<double,0,1,2,3,4>
without generating an implementation:
https://godbolt.org/z/9Mv67GeYW
What is going on? Did I get into IFNDR territory?
Upvotes: 5
Views: 252
Reputation: 4655
I think this is a bug in clang, and it seems to be fixed in Clang 15.
This code seems to expose the same issue, warns in clang < 15 and not in clang >= 15.
class A {
template <char N>
struct Foo {
static constexpr char Bar() { return 0; }
};
using Constants = Foo<1>;
char var = Constants::Bar();
};
Upvotes: 3