[Bug c++/78173] New: Hard error subtracting pointers to incomplete type in SFINAE context
Casey at Carter dot net
gcc-bugzilla@gcc.gnu.org
Mon Oct 31 17:32:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78173
Bug ID: 78173
Summary: Hard error subtracting pointers to incomplete type in
SFINAE context
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: Casey at Carter dot net
Target Milestone: ---
Created attachment 39934
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39934&action=edit
Minimal repro
This TU, which should compile without errors:
template<class T>
T&& declval();
template<class...>
using void_t = void;
template<class, class = void>
struct foo { static const bool value = false; };
template<class T>
struct foo<T, void_t<decltype(declval<T>() - declval<T>())>> {
static const bool value = true;
};
struct A;
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
STATIC_ASSERT(!foo<void*>::value); // error: invalid use of 'void'
STATIC_ASSERT(!foo<A*>::value); // error: invalid use of incomplete type
'struct A'
instead produces diagnostics
(http://melpon.org/wandbox/permlink/EwcDiz7ZuqpFXdHZ):
prog.cc: In substitution of 'template<class T> struct foo<T, void_t<decltype
((declval<T>() - declval<T>()))> > [with T = void*]':
prog.cc:22:1: required from here
prog.cc:10:44: error: invalid use of 'void'
struct foo<T, void_t<decltype(declval<T>() - declval<T>())>> {
~~~~~~~~~~~~~^~~~~~~~~~~~~~
prog.cc: In substitution of 'template<class T> struct foo<T, void_t<decltype
((declval<T>() - declval<T>()))> > [with T = A*]':
prog.cc:23:1: required from here
prog.cc:10:44: error: invalid use of incomplete type 'struct A'
prog.cc:14:8: note: forward declaration of 'struct A'
struct A;
^
More information about the Gcc-bugs
mailing list