Bug 48744 - [C++0x][SFINAE] Hard errors with list-initialization and void initializers
Summary: [C++0x][SFINAE] Hard errors with list-initialization and void initializers
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-23 21:38 UTC by Daniel Krügler
Modified: 2011-05-09 19:27 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-05-08 15:18:36


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Krügler 2011-04-23 21:38:55 UTC
gcc 4.7.0 20110422 (experimental) in C++0x mode rejects the following code
at the line marked with #:

//-------------------------
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 Arg>
decltype(T{create<Arg>()}, char()) f(int);

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

static_assert(sizeof(f<int, void>(0)) != 1, "Error"); // #
//-------------------------

"error: void value not ignored as it ought to be"

The code should be accepted.
Comment 1 Paolo Carlini 2011-05-08 15:18:36 UTC
Working on this one.
Comment 2 paolo@gcc.gnu.org 2011-05-09 19:24:53 UTC
Author: paolo
Date: Mon May  9 19:24:50 2011
New Revision: 173590

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173590
Log:
/cp
2011-05-09  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/48737
	PR c++/48744
	* decl.c (reshape_init): Take a complain parameter and do
	not call error if tf_error is not set.
	(check_initializer, reshape_init_r, reshape_init_array,
	reshape_init_array_1, reshape_init_vector, reshape_init_class):
	Adjust.
	* typeck2.c (digest_init_r): Take a complain parameter and
	pass it to convert_for_initialization.
	(digest_init, digest_init_flags, process_init_constructor_array,
	process_init_constructor_record, process_init_constructor_union,
	process_init_constructor, digest_init_r): Adjust.
	* init.c (expand_default_init, build_new_1): Likewise.
	* typeck.c (cp_build_modify_expr): Likewise.
	* decl2.c (grokfield): Likewise.
	* call.c (convert_like_real, convert_default_arg): Likewise.
	* semantics.c (finish_compound_literal): Pass complain to
	reshape_init and digest_init.
	* cp-tree.h: Adjust declarations.

/testsuite
2011-05-09  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/48737
	PR c++/48744
	* g++.dg/template/sfinae28.C: New.
	* g++.dg/template/sfinae29.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/template/sfinae28.C
    trunk/gcc/testsuite/g++.dg/template/sfinae29.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/decl2.c
    trunk/gcc/cp/init.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/cp/typeck.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Paolo Carlini 2011-05-09 19:27:28 UTC
Done.