public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54738] New: [C++11][SFINAE] Hard errors for pointer-to-member function expressions
@ 2012-09-28 22:24 daniel.kruegler at googlemail dot com
  2012-09-28 23:12 ` [Bug c++/54738] " 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-09-28 22:24 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 54738
           Summary: [C++11][SFINAE] Hard errors for pointer-to-member
                    function expressions
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com


During my attempts to implement sfinae-friendly result_of I found the following
problems using gcc 4.8.0 20120923 (experimental) with compile-flags

-Wall -pedantic -std=c++0x

with pointer-to-member function expressions. 

First there are problems if we have an incompatible number of function call
arguments:

//---
template<class T>
T&& declval();

template<class F, class T1, class... Ts>
decltype(((*declval<T1>()).*declval<F>())(declval<Ts>()...))
test1(int);

template<class...>
void test1(...);

template<class F, class T1, class... Ts>
decltype((declval<T1>().*declval<F>())(declval<Ts>()...))
test2(int);

template<class...>
void test2(...);

struct S {};

typedef void (S::*Func)(int) const;

typedef decltype(test1<Func, S*>(0)) type1a;  // #22
typedef decltype(test1<Func, S*&>(0)) type1b;
typedef decltype(test1<Func, S*, int, int>(0)) type1c;
typedef decltype(test1<Func, S*&, int, int>(0)) type1d;

typedef decltype(test2<Func, S>(0)) type2a; // #27
typedef decltype(test2<Func, S&>(0)) type2b;
typedef decltype(test2<Func, S, int, int>(0)) type2c;
typedef decltype(test2<Func, S&, int, int>(0)) type2d;
//---

The error messages are:

<quote>
22|  required from here|
6|error: too few arguments to function|
22|  required from here|
6|error: too few arguments to function|
23|  required from here|
6|error: too few arguments to function|
23|  required from here|
6|error: too few arguments to function|
24|  required from here|
6|error: too many arguments to function|
25|  required from here|
6|error: too many arguments to function|
27|  required from here|
13|error: too few arguments to function|
27|  required from here|
13|error: too few arguments to function|
28|  required from here|
13|error: too few arguments to function|
28|  required from here|
13|error: too few arguments to function|
29|  required from here|
13|error: too many arguments to function|
30|  required from here|
13|error: too many arguments to function|
</quote>

Further there are also problems with corresponding function call expressions
where the arguments won't convert:

//---
template<class T>
T&& declval();

template<class F, class T1, class... Ts>
decltype(((*declval<T1>()).*declval<F>())(declval<Ts>()...))
test1(int);

template<class...>
void test1(...);

template<class F, class T1, class... Ts>
decltype((declval<T1>().*declval<F>())(declval<Ts>()...))
test2(int);

template<class...>
void test2(...);

struct S {};

typedef void (S::*Func)(int) const;

typedef decltype(test1<Func, S*, S>(0)) type3a; // #22
typedef decltype(test1<Func, S*&, S>(0)) type3b;

typedef decltype(test2<Func, S, S>(0)) type4a; // #25
typedef decltype(test2<Func, S&, S>(0)) type4b;
//---

The error messages are:

<quote>
22|  required from here|
6|error: cannot convert 'S' to 'int' in argument passing|
22|  required from here|
6|error: cannot convert 'S' to 'int' in argument passing|
23|  required from here|
6|error: cannot convert 'S' to 'int' in argument passing|
23|  required from here|
6|error: cannot convert 'S' to 'int' in argument passing|
25|  required from here|
13|error: cannot convert 'S' to 'int' in argument passing|
25|  required from here|
13|error: cannot convert 'S' to 'int' in argument passing|
26|  required from here|
13|error: cannot convert 'S' to 'int' in argument passing|
26|  required from here|
13|error: cannot convert 'S' to 'int' in argument passing|
</quote>

Further cv-violations aren't sfinaed away:

//---
template<class T>
T&& declval();

template<class F, class T1, class... Ts>
decltype(((*declval<T1>()).*declval<F>())(declval<Ts>()...))
test1(int);

template<class...>
void test1(...);

template<class F, class T1, class... Ts>
decltype((declval<T1>().*declval<F>())(declval<Ts>()...))
test2(int);

template<class...>
void test2(...);

struct S {};

typedef void (S::*Func2)(int);

typedef decltype(test1<Func2, const S*, int>(0)) type5a; // #22
typedef decltype(test1<Func2, const S*&, int>(0)) type5b;

typedef decltype(test2<Func2, const S, int>(0)) type6a; // #25
typedef decltype(test2<Func2, const S&, int>(0)) type6b;
//---

The error messages are:

<quote>
22|  required from here|
6|error: invalid conversion from 'const S*' to 'S*' [-fpermissive]|
23|  required from here|
6|error: invalid conversion from 'const S*' to 'S*' [-fpermissive]|
25|  required from here|
13|error: invalid conversion from 'const S*' to 'S*' [-fpermissive]|
26|  required from here|
13|error: invalid conversion from 'const S*' to 'S*' [-fpermissive]|
</quote>

These code examples should all be accepted.


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

* [Bug c++/54738] [C++11][SFINAE] Hard errors for pointer-to-member function expressions
  2012-09-28 22:24 [Bug c++/54738] New: [C++11][SFINAE] Hard errors for pointer-to-member function expressions daniel.kruegler at googlemail dot com
@ 2012-09-28 23:12 ` paolo.carlini at oracle dot com
  2012-09-28 23:12 ` 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-09-28 23:12 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED


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

* [Bug c++/54738] [C++11][SFINAE] Hard errors for pointer-to-member function expressions
  2012-09-28 22:24 [Bug c++/54738] New: [C++11][SFINAE] Hard errors for pointer-to-member function expressions daniel.kruegler at googlemail dot com
  2012-09-28 23:12 ` [Bug c++/54738] " paolo.carlini at oracle dot com
@ 2012-09-28 23:12 ` paolo.carlini at oracle dot com
  2012-09-29 22:58 ` paolo at gcc dot gnu.org
  2012-09-29 23:00 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-09-28 23:12 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-09-28
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com
   Target Milestone|---                         |4.8.0
     Ever Confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-09-28 23:12:08 UTC ---
Ok, I have a simple patch fixing all of them.


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

* [Bug c++/54738] [C++11][SFINAE] Hard errors for pointer-to-member function expressions
  2012-09-28 22:24 [Bug c++/54738] New: [C++11][SFINAE] Hard errors for pointer-to-member function expressions daniel.kruegler at googlemail dot com
  2012-09-28 23:12 ` [Bug c++/54738] " paolo.carlini at oracle dot com
  2012-09-28 23:12 ` paolo.carlini at oracle dot com
@ 2012-09-29 22:58 ` paolo at gcc dot gnu.org
  2012-09-29 23:00 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-09-29 22:58 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-09-29 22:58:36 UTC ---
Author: paolo
Date: Sat Sep 29 22:58:31 2012
New Revision: 191862

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

    PR c++/54738
    * decl2.c (build_offset_ref_call_from_tree): Add tsubst_flags_t
    parameter.
    * pt.c (tsubst_copy_and_build): Adjust.
    * parser.c (cp_parser_postfix_expression): Likewise.
    * cp-tree.h: Adjust declaration.

/testsuite
2012-09-29  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/54738
    * g++.dg/cpp0x/sfinae42.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/sfinae42.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl2.c
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/54738] [C++11][SFINAE] Hard errors for pointer-to-member function expressions
  2012-09-28 22:24 [Bug c++/54738] New: [C++11][SFINAE] Hard errors for pointer-to-member function expressions daniel.kruegler at googlemail dot com
                   ` (2 preceding siblings ...)
  2012-09-29 22:58 ` paolo at gcc dot gnu.org
@ 2012-09-29 23:00 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-09-29 23:00 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-09-29 23:00:10 UTC ---
Fixed.


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

end of thread, other threads:[~2012-09-29 23:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-28 22:24 [Bug c++/54738] New: [C++11][SFINAE] Hard errors for pointer-to-member function expressions daniel.kruegler at googlemail dot com
2012-09-28 23:12 ` [Bug c++/54738] " paolo.carlini at oracle dot com
2012-09-28 23:12 ` paolo.carlini at oracle dot com
2012-09-29 22:58 ` paolo at gcc dot gnu.org
2012-09-29 23:00 ` 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).