Clang produces different result for Full template specialization
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
The following program produces `0` in clang while `1` in gcc and msvc irrespective of whether you use `=delete` or `{}` when defining the `format` function template. [Demo with `=delete`](https://godbolt.org/z/Wz58Pr8fT) and [Demo without `=delete`](https://godbolt.org/z/8cYnTKhe7)
```c++
#include
#include
#include
namespace my_namespace {
template
void format(std::ostream& os, const T& t) =delete; //replacing =delete with {} still produces 0 in clang
template
struct is_formattable : std::false_type { };
template
struct is_formattable(std::declval(), std::declval()), void { })> : std::true_type { };
}
struct S {
int a;
};
namespace my_namespace {
template <>
void format<::S>(std::ostream& os, const ::S& s)
{
os << "S[" << s.a << ']';
}
}
int main() { std::cout << my_namespace::is_formattable::value << '\n'; }
```
Contributor guide
Research direction
Start by compiling the reduced C++ program in the issue and compare Clang's result with GCC, MSVC, and the linked Compiler Explorer examples. Determine which result matches the applicable C++ template-specialization rules, then use that finding to define the expected Clang behavior and validate any change against the reproducer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100