efcs / llvm-project

This is the canonical git mirror of the LLVM subversion repository. The repository does not accept github pull requests at this moment. Please submit your patches at http://reviews.llvm.org.
http://llvm.org
Other
0 stars 0 forks source link

Template with explicit instantiation causes constructor precondition to fail #6

Open PeterBindels-TomTom opened 1 week ago

PeterBindels-TomTom commented 1 week ago
template <size_t bits>
class t {
  explicit t(std::span<const uint8_t> f) pre(f.size() == bits/8);
};

template <>
t<128>::t(std::span<const uint8_t> f) {}

Does not want to reduce much further than this. It turns out that the explicit instantiation is required for this to trigger, but I have no idea why.

EricWF commented 1 week ago

Does not want to reduce much further than this. It turns out that the explicit instantiation is required for this to trigger, but I have no idea why.

I think that's an explicit specialization, rather than instantiation.

The explicit instantiation "works", but also this test case shook out like 3 more bugs:

https://godbolt.org/z/dEf75dG9d