public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52422] New: [C++11][SFINAE] Hard errors with void or arithmetic expressions
@ 2012-02-28 20:10 daniel.kruegler at googlemail dot com
  2012-02-28 20:43 ` [Bug c++/52422] " paolo.carlini at oracle dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-02-28 20:10 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52422

             Bug #: 52422
           Summary: [C++11][SFINAE] Hard errors with void or arithmetic
                    expressions
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com


gcc 4.7.0 20120225 (experimental) in C++11 mode produces a hard compiler error
during a sfinae-conforming situation involving function-like or pointer-like
expressions:

//---
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 = decltype(create<T>()()) // line 17
>
auto f(int) -> char(&)[1];

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

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

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

Here some further variations of the theme:

a) Replace line 17 by

class = decltype(*create<T>()) // line 17

b) Replace above test by

//---
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>())() ) // line 17
>
auto f(int) -> char(&)[1];

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

static_assert(sizeof(f<void, void>(0)) != 1, ""); // line 24
//---

"17|error: 'create<void>()' cannot be used as a member pointer, since it is of
type 'add_rval_ref<void>::type {aka void}'"

c) Replace in the test (b) line 24 by the following line:

static_assert(sizeof(f<int, int>(0)) != 1, ""); // line 24

"17|error: 'create<int>()' cannot be used as a member pointer, since it is of
type 'int'"

d) Replace line 17 in the test (b) by the following line and use either of
"void, void" or "int, int" as template arguments in line 24:

class = decltype( create<T>().*create<U>() )

"17|error: 'create<void>()' cannot be used as a member pointer, since it is of
type 'add_rval_ref<void>::type {aka void}'"

or

"17|error: 'create<int>()' cannot be used as a member pointer, since it is of
type 'int'"

respectively.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/52422] [C++11][SFINAE] Hard errors with void or arithmetic expressions
  2012-02-28 20:10 [Bug c++/52422] New: [C++11][SFINAE] Hard errors with void or arithmetic expressions daniel.kruegler at googlemail dot com
@ 2012-02-28 20:43 ` paolo.carlini at oracle dot com
  2012-02-28 23:41 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-02-28 20:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52422

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-02-28
     Ever Confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-02-28 20:38:06 UTC ---
Ok. Likely simple to fix, I'll have a look.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/52422] [C++11][SFINAE] Hard errors with void or arithmetic expressions
  2012-02-28 20:10 [Bug c++/52422] New: [C++11][SFINAE] Hard errors with void or arithmetic expressions daniel.kruegler at googlemail dot com
  2012-02-28 20:43 ` [Bug c++/52422] " paolo.carlini at oracle dot com
@ 2012-02-28 23:41 ` paolo.carlini at oracle dot com
  2012-04-18 10:27 ` paolo at gcc dot gnu.org
  2012-04-18 10:32 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-02-28 23:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52422

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com
   Target Milestone|---                         |4.8.0

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-02-28 23:18:42 UTC ---
As expected pretty straightforward, essentially matter of propagating complain
to decay_conversion and build_m_component_ref.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/52422] [C++11][SFINAE] Hard errors with void or arithmetic expressions
  2012-02-28 20:10 [Bug c++/52422] New: [C++11][SFINAE] Hard errors with void or arithmetic expressions daniel.kruegler at googlemail dot com
  2012-02-28 20:43 ` [Bug c++/52422] " paolo.carlini at oracle dot com
  2012-02-28 23:41 ` paolo.carlini at oracle dot com
@ 2012-04-18 10:27 ` paolo at gcc dot gnu.org
  2012-04-18 10:32 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-04-18 10:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52422

--- Comment #3 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-04-18 10:21:52 UTC ---
Author: paolo
Date: Wed Apr 18 10:21:43 2012
New Revision: 186565

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186565
Log:
/cp
2012-04-18  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/52422
    * cp-tree.h (build_addr_func, decay_conversion,
    get_member_function_from_ptrfunc,
    build_m_component_ref, convert_member_func_to_ptr):
    Add tsubst_flags_t parameter.
    * typeck.c (cp_default_conversion): Add.
    (decay_conversion, default_conversion,
    get_member_function_from_ptrfunc, convert_member_func_to_ptr):
    Add tsubst_flags_t parameter and use it throughout.
    (cp_build_indirect_ref, cp_build_array_ref,
    cp_build_function_call_vec, convert_arguments, build_x_binary_op,
    cp_build_binary_op, cp_build_unary_op, build_reinterpret_cast_1,
    build_const_cast_1, expand_ptrmemfunc_cst,
    convert_for_initialization): Adjust.
    * init.c (build_vec_init): Adjust.
    * decl.c (grok_reference_init, get_atexit_node): Likewise.
    * rtti.c (build_dynamic_cast_1, tinfo_base_init): Likewise.
    * except.c (build_throw): Likewise.
    * typeck2.c (build_x_arrow): Likewise.
    (build_m_component_ref): Add tsubst_flags_t parameter and
    use it throughout.
    * pt.c (convert_nontype_argument): Adjust.
    * semantics.c (finish_asm_stmt, maybe_add_lambda_conv_op): Likewise.
    * decl2.c (build_offset_ref_call_from_tree): Likewise.
    * call.c (build_addr_func): Add tsubst_flags_t parameter and
    use it throughout.
    (build_call_a, build_conditional_expr_1, build_new_op_1,
    convert_like_real, convert_arg_to_ellipsis, build_over_call,
    build_special_member_call): Adjust.
    * cvt.c (cp_convert_to_pointer, force_rvalue,
    build_expr_type_conversion): Likewise.

/testsuite
2012-04-18  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/52422
    * g++.dg/cpp0x/sfinae33.C: New.
    * g++.dg/cpp0x/sfinae34.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/sfinae33.C
    trunk/gcc/testsuite/g++.dg/cpp0x/sfinae34.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/cvt.c
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/decl2.c
    trunk/gcc/cp/except.c
    trunk/gcc/cp/init.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/rtti.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/cp/typeck.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/52422] [C++11][SFINAE] Hard errors with void or arithmetic expressions
  2012-02-28 20:10 [Bug c++/52422] New: [C++11][SFINAE] Hard errors with void or arithmetic expressions daniel.kruegler at googlemail dot com
                   ` (2 preceding siblings ...)
  2012-04-18 10:27 ` paolo at gcc dot gnu.org
@ 2012-04-18 10:32 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-18 10:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52422

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
              Alias|jason at gcc dot gnu.org    |

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-18 10:23:56 UTC ---
Fixed for 4.8.0.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-04-18 10:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-28 20:10 [Bug c++/52422] New: [C++11][SFINAE] Hard errors with void or arithmetic expressions daniel.kruegler at googlemail dot com
2012-02-28 20:43 ` [Bug c++/52422] " paolo.carlini at oracle dot com
2012-02-28 23:41 ` paolo.carlini at oracle dot com
2012-04-18 10:27 ` paolo at gcc dot gnu.org
2012-04-18 10:32 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).