This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/48557] New: [C++0x][SFINAE] Hard errors with void as operand of binary built-in operators
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 11 Apr 2011 18:04:13 +0000
- Subject: [Bug c++/48557] New: [C++0x][SFINAE] Hard errors with void as operand of binary built-in operators
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48557
Summary: [C++0x][SFINAE] Hard errors with void as operand of
binary built-in operators
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: daniel.kruegler@googlemail.com
CC: jason@redhat.com
Build: 4.7.0 20110409 (experimental)
The following program is well-formed, but should be well-formed according to
SFINAE rules:
//-----------------
template<class T>
struct add_rval_ref
{
typedef T&& type;
};
template<>
struct add_rval_ref<void>
{
typedef void type;
};
template<class T>
typename add_rval_ref<T>::type create();
template<class T, class U,
class = decltype(create<T>() + create<U>())
>
char f(int);
template<class, class>
char (&f(...))[2];
static_assert(sizeof(f<void, int>(0)) != 1, "Error"); // (a)
//-----------------
The error message at (a) is:
"error: void value not ignored as it ought to be"
The same problem has been confirmed to exist for the following binary
operators:
+,-,*,/,%,<<,>>,==,!=,<,<=,>,>=,&,^,|,&&,||
It does *not* occur for the corresponding compounds assignments, like +=,
though