llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.4k stars 12.15k forks source link

3+ parameter common_type isn't sufficiently SFINAE-friendly #30829

Closed 7318a870-54d1-4d9b-a5cf-8ce660251251 closed 7 years ago

7318a870-54d1-4d9b-a5cf-8ce660251251 commented 7 years ago
Bugzilla Link 31481
Resolution FIXED
Resolved on Dec 27, 2016 15:17
Version unspecified
OS All
CC @mclow

Extended Description

include

struct A {}; template class std::common_type<int, int, A>;

In file included from prog.cc:1: /usr/local/llvm-head/include/c++/v1/type_traits:2029:8: error: no type named 'type' in 'std::__1::common_type<int, A>'

::type type;


/usr/local/llvm-head/include/c++/v1/type_traits:2034:7: note: in instantiation of template class 'std::__1::__common_type_impl<std::__1::__common_types<int, int, A>, void>' requested here
: __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
^
prog.cc:4:22: note: in instantiation of template class 'std::__1::common_type<int, int, A>' requested here
template struct std::common_type<int, int, A>;
^

The __void_t check for this case only verified the existence of common_type<_Tp, _Up>::type, not common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type. The simplest fix is to inherit from common_type<typename common_type<_Tp, _Up>::type, _Vp...> instead.

Of course, P0435R1 is touching this area again, but the principal change is to the two-parameter version and not >2, so figured I'd file this anyway.

llvmbot commented 7 years ago

This bug was fixed in r290624 (4.0). I also implemented P0435R1 in r290627.

Thanks for the report.