Bug 48452 - [C++0x][SFINAE] Failures with n-ary initialization expressions (in return type)
[C++0x][SFINAE] Failures with n-ary initialization expressions (in return type)
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: c++
4.7.0
: P3 normal
: 4.6.1
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-05 06:54 UTC by Daniel Krügler
Modified: 2011-04-08 15:13 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Krügler 2011-04-05 06:54:11 UTC
Some n-ary initialization expressions in a SFINAE context used in a return type definition either give hard errors:

  a) any T => abstract class
  b) cv void => T (T is a class type)

or give the wrong result:

  c) when void is initialized with more than one argument

#include <utility> // for declval

template<class T, class... Args>
decltype(T(std::declval<Args>()...), char()) f(int);

template<class, class...>
char (&f(...))[2];

struct A { virtual ~A() = 0; };
struct B {};

static_assert(sizeof(f<A, int, int>(0)) != 1, "Error"); // a
static_assert(sizeof(f<B, void, int>(0)) != 1, "Error"); // b
static_assert(sizeof(f<void, int, int>(0)) != 1, "Error"); // c

a) "error: cannot allocate an object of abstract type 'A' because the
following virtual functions are pure within 'A': virtual A::~A()"
b) "error: invalid use of void expression"
c) Assertion triggers!
Comment 1 Jason Merrill 2011-04-07 21:47:55 UTC
Author: jason
Date: Thu Apr  7 21:47:53 2011
New Revision: 172147

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172147
Log:
	PR c++/48452
	* typeck.c (build_x_compound_expr_from_list): Return error_mark_node
	in SFINAE context.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/sfinae10.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Jason Merrill 2011-04-08 15:02:12 UTC
Author: jason
Date: Fri Apr  8 15:02:08 2011
New Revision: 172193

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172193
Log:
	PR c++/48452
	* typeck.c (build_x_compound_expr_from_list): Return error_mark_node
	in SFINAE context.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/sfinae10.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/typeck.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 3 Jason Merrill 2011-04-08 15:13:41 UTC
Fixed for 4.6.1.