public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/19076] New: Pointer to member function not matched
@ 2004-12-19  9:57 pcarlini at suse dot de
  2004-12-19 13:40 ` [Bug c++/19076] " pinskia at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: pcarlini at suse dot de @ 2004-12-19  9:57 UTC (permalink / raw)
  To: gcc-bugs

This is not a regression, but seems a serious problem, which, actually, is
blocking a simple implementation of various tr1/type_traits facilities :(

The following simplified testcase fails: for some reason, pointers to member
functions (vs, pointers to member objects) are not matched. ICC has no 
problems at all with it.

//---------------------------------------------
#include <cassert>

template<bool _Tv>
  struct integral_constant
  {
    static const bool               value = _Tv;
  };
typedef integral_constant<true>     true_type;
typedef integral_constant<false>    false_type;

template<typename>
  struct is_member_pointer
  : public false_type { };

template<typename _Tp, typename _Cp>
  struct is_member_pointer<_Tp _Cp::*>
  : public true_type { };

typedef void F();
struct S {};
typedef F S::*PMF;

int main()
{
  assert( is_member_pointer<PMF>::value );
}
//-----------------------------------------------

-- 
           Summary: Pointer to member function not matched
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pcarlini at suse dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: Any
  GCC host triplet: Any
GCC target triplet: Any


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


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

* [Bug c++/19076] Pointer to member function not matched
  2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
@ 2004-12-19 13:40 ` pinskia at gcc dot gnu dot org
  2004-12-19 20:02 ` bangerth at dealii dot org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-19 13:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-19 13:40 -------
Confirmed.
Here is a compile time test instead of a runtime test (it is easier to keep track of):
template<typename _Tp1>
  struct is_member_pointer { void f(){_Tp1 t = 100;}};

template<typename _Tp, typename _Cp>
  struct is_member_pointer<_Tp _Cp::*> {void f(){}};

struct S {void f(void);};
typedef void (S::*PMF)(void);

int main()
{
  is_member_pointer<PMF> i;
  i.f();
}

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |accepts-invalid, rejects-
                   |                            |valid, wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-12-19 13:40:13
               date|                            |


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


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

* [Bug c++/19076] Pointer to member function not matched
  2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
  2004-12-19 13:40 ` [Bug c++/19076] " pinskia at gcc dot gnu dot org
@ 2004-12-19 20:02 ` bangerth at dealii dot org
  2004-12-19 22:19 ` [Bug c++/19076] Pointer to member function not matched to pointer to member template bangerth at dealii dot org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bangerth at dealii dot org @ 2004-12-19 20:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-12-19 20:01 -------
Why not the minimal testcase: 
--------------------- 
template <typename>                  struct X; 
template<typename _Tp, typename _Cp> struct X<_Tp _Cp::*> {}; 
 
typedef int F(); 
 
struct S { F f; }; 
typedef F S::*PMF; 
 
X<PMF> s; 
-------------------- 
g/x> c++ -c x.cc 
x.cc:9: error: aggregate `X<int (S::*)()> s' has incomplete type and cannot be  
   defined 
x.cc:9: error: storage size of `s' isn't known 
 
g/x> icc -c x.cc 
 
 
The problem is really that F is a reference to a function. If we define 
the typedef as 
  typedef int F; 
then everything is fine. 
 
W. 

-- 


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


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

* [Bug c++/19076] Pointer to member function not matched to pointer to member template
  2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
  2004-12-19 13:40 ` [Bug c++/19076] " pinskia at gcc dot gnu dot org
  2004-12-19 20:02 ` bangerth at dealii dot org
@ 2004-12-19 22:19 ` bangerth at dealii dot org
  2004-12-20 12:29 ` reichelt at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bangerth at dealii dot org @ 2004-12-19 22:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-12-19 22:19 -------
I should have been more clear: the problem is with matching a pointer- 
to-member-function with a pointer-to-member template. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Pointer to member function  |Pointer to member function
                   |not matched                 |not matched to pointer to
                   |                            |member template


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


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

* [Bug c++/19076] Pointer to member function not matched to pointer to member template
  2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
                   ` (2 preceding siblings ...)
  2004-12-19 22:19 ` [Bug c++/19076] Pointer to member function not matched to pointer to member template bangerth at dealii dot org
@ 2004-12-20 12:29 ` reichelt at gcc dot gnu dot org
  2004-12-20 13:25 ` giovannibajo at libero dot it
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-12-20 12:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From reichelt at gcc dot gnu dot org  2004-12-20 12:29 -------
Here's an even simpler testcase: 
 
============================================ 
typedef int F(); 
 
struct A { F f; }; 
 
template<typename>   struct B; 
template<typename T> struct B<T A::*> {}; 
 
B<F A::*> b; 
============================================ 
 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |reichelt at gcc dot gnu dot
                   |                            |org
  GCC build triplet|Any                         |
   GCC host triplet|Any                         |
 GCC target triplet|Any                         |
           Keywords|                            |monitored


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


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

* [Bug c++/19076] Pointer to member function not matched to pointer to member template
  2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
                   ` (3 preceding siblings ...)
  2004-12-20 12:29 ` reichelt at gcc dot gnu dot org
@ 2004-12-20 13:25 ` giovannibajo at libero dot it
  2004-12-20 13:40 ` pcarlini at suse dot de
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: giovannibajo at libero dot it @ 2004-12-20 13:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-12-20 13:25 -------
Does this require the member function to be *declared* through the typedef? 
Otherwise I think it looks easier to understand where the bug is if the 
testcase uses a normal declaration for the member function inside the class 
definition.

-- 


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


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

* [Bug c++/19076] Pointer to member function not matched to pointer to member template
  2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
                   ` (4 preceding siblings ...)
  2004-12-20 13:25 ` giovannibajo at libero dot it
@ 2004-12-20 13:40 ` pcarlini at suse dot de
  2004-12-20 15:15 ` bangerth at dealii dot org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pcarlini at suse dot de @ 2004-12-20 13:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-12-20 13:40 -------
Hi Giovanni. Indeed, I don't think typedefs are directly involved and probably
we can further simplify like this:

===========================================
struct A {}; 
 
template<typename>   struct B; 
template<typename T> struct B<T A::*> {}; 
 
B<void(A::*)()> b;
===========================================

-- 


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


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

* [Bug c++/19076] Pointer to member function not matched to pointer to member template
  2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
                   ` (5 preceding siblings ...)
  2004-12-20 13:40 ` pcarlini at suse dot de
@ 2004-12-20 15:15 ` bangerth at dealii dot org
  2004-12-25 18:48 ` giovannibajo at libero dot it
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bangerth at dealii dot org @ 2004-12-20 15:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-12-20 15:15 -------
This last testcase indeed still shows the problem. It doesn't compile 
with gcc, but does with icc. 
W. 

-- 


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


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

* [Bug c++/19076] Pointer to member function not matched to pointer to member template
  2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
                   ` (6 preceding siblings ...)
  2004-12-20 15:15 ` bangerth at dealii dot org
@ 2004-12-25 18:48 ` giovannibajo at libero dot it
  2005-01-20 18:02 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: giovannibajo at libero dot it @ 2004-12-25 18:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-12-25 18:48 -------
I played with this briefly, and the bug is non-trivial.

Our internal representation for pointer-to-member-data and pointer-to-member-
function is totally different and incompatible, and pt.c isn't ready at all to 
convert so freely from one to another. I think we need to patch at least unify 
(to handle deduction of ptmf through dependent ptmd), tsubst (to perform the 
actual substitution), and convert_nontype_argument (to handle constants ptmf in 
the form &A::f passed to template functions).

I doubt any patch for this would qualify for 4.0. Nathan said he has a secret 
plan for 4.1, so maybe he can share it with us since it's christmas :)

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nathan at gcc dot gnu dot
                   |                            |org


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


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

* [Bug c++/19076] Pointer to member function not matched to pointer to member template
  2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
                   ` (7 preceding siblings ...)
  2004-12-25 18:48 ` giovannibajo at libero dot it
@ 2005-01-20 18:02 ` pinskia at gcc dot gnu dot org
  2005-01-21  1:02 ` giovannibajo at libero dot it
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-20 18:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-20 18:02 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-01/msg01341.html>.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


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


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

* [Bug c++/19076] Pointer to member function not matched to pointer to member template
  2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
                   ` (8 preceding siblings ...)
  2005-01-20 18:02 ` pinskia at gcc dot gnu dot org
@ 2005-01-21  1:02 ` giovannibajo at libero dot it
  2005-01-21  1:05 ` giovannibajo at libero dot it
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: giovannibajo at libero dot it @ 2005-01-21  1:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2005-01-21 01:02 -------
Uhm, I wrote a very similar patch in the past only to find out it was not 
enough. There is something I cannot understand...

-- 


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


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

* [Bug c++/19076] Pointer to member function not matched to pointer to member template
  2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
                   ` (9 preceding siblings ...)
  2005-01-21  1:02 ` giovannibajo at libero dot it
@ 2005-01-21  1:05 ` giovannibajo at libero dot it
  2005-01-26 10:25 ` pcarlini at suse dot de
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: giovannibajo at libero dot it @ 2005-01-21  1:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2005-01-21 01:05 -------
Ah well, I guess this patch is not enough for this:

---------------------------
struct A {
   void func(void);
};

template <class T>
void foo(T A::* );

void bar(void) {
   foo(&A::func);
}
---------------------------

which is about where I stopped. 

-- 


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


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

* [Bug c++/19076] Pointer to member function not matched to pointer to member template
  2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
                   ` (10 preceding siblings ...)
  2005-01-21  1:05 ` giovannibajo at libero dot it
@ 2005-01-26 10:25 ` pcarlini at suse dot de
  2005-02-22  4:02 ` cvs-commit at gcc dot gnu dot org
  2005-02-22  7:28 ` pcarlini at suse dot de
  13 siblings, 0 replies; 15+ messages in thread
From: pcarlini at suse dot de @ 2005-01-26 10:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2005-01-26 10:25 -------
New patch here: http://gcc.gnu.org/ml/gcc-patches/2005-01/msg01627.html

-- 


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


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

* [Bug c++/19076] Pointer to member function not matched to pointer to member template
  2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
                   ` (11 preceding siblings ...)
  2005-01-26 10:25 ` pcarlini at suse dot de
@ 2005-02-22  4:02 ` cvs-commit at gcc dot gnu dot org
  2005-02-22  7:28 ` pcarlini at suse dot de
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-02-22  4:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-02-21 23:12 -------
Subject: Bug 19076

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	paolo@gcc.gnu.org	2005-02-21 23:12:28

Modified files:
	gcc/cp         : ChangeLog cp-tree.h decl.c decl2.c error.c pt.c 
	                 tree.c typeck.c 

Log message:
	2005-02-21  Douglas Gregor  <dgregor@cs.indiana.edu>
	
	PR c++/19076
	PR c++/6628
	* cp-tree.h (cp_apply_type_quals_to_decl): Declared.
	* decl.c (grokdeclarator): Pedwarn about qualifying a function
	type.
	Add qualifiers when declaring a typedef of a function type.
	Member function pointers pick up the qualifiers of the typedef
	used to declare them.
	Don't complain about creating cv-qualified function types.
	Complain about qualified function typedefs that are used to
	declare non-static member functions or free functions.
	Use cp_apply_type_quals_to_decl.
	(start_preparsed_function): Use cp_apply_type_quals_to_decl.
	(grokclassfn): Use cp_apply_type_quals_to_decl.
	* error.c (dump_type_suffix): Print qualifiers for function
	types.
	* pt.c (tsubst_decl): Use cp_apply_type_quals_to_decl.
	(tsubst): When substituting a function type into a member
	pointer type, pass along the qualifiers.
	(unify): Unify member pointers to member function pointers.
	* tree.c (cp_build_qualified_type_real): Function types may be
	qualified. This includes restrict qualifiers.
	* typeck.c (cp_apply_type_quals_to_decl): New function to replace
	use of c_apply_type_quals_to_decl. Drops qualifiers that are being
	added to function types.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4639&r2=1.4640
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1104&r2=1.1105
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1366&r2=1.1367
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.767&r2=1.768
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/error.c.diff?cvsroot=gcc&r1=1.275&r2=1.276
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.977&r2=1.978
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&r1=1.426&r2=1.427
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.614&r2=1.615



-- 


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


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

* [Bug c++/19076] Pointer to member function not matched to pointer to member template
  2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
                   ` (12 preceding siblings ...)
  2005-02-22  4:02 ` cvs-commit at gcc dot gnu dot org
@ 2005-02-22  7:28 ` pcarlini at suse dot de
  13 siblings, 0 replies; 15+ messages in thread
From: pcarlini at suse dot de @ 2005-02-22  7:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2005-02-21 23:50 -------
Fixed for 4.0.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.0.0


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


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

end of thread, other threads:[~2005-02-21 23:50 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-19  9:57 [Bug c++/19076] New: Pointer to member function not matched pcarlini at suse dot de
2004-12-19 13:40 ` [Bug c++/19076] " pinskia at gcc dot gnu dot org
2004-12-19 20:02 ` bangerth at dealii dot org
2004-12-19 22:19 ` [Bug c++/19076] Pointer to member function not matched to pointer to member template bangerth at dealii dot org
2004-12-20 12:29 ` reichelt at gcc dot gnu dot org
2004-12-20 13:25 ` giovannibajo at libero dot it
2004-12-20 13:40 ` pcarlini at suse dot de
2004-12-20 15:15 ` bangerth at dealii dot org
2004-12-25 18:48 ` giovannibajo at libero dot it
2005-01-20 18:02 ` pinskia at gcc dot gnu dot org
2005-01-21  1:02 ` giovannibajo at libero dot it
2005-01-21  1:05 ` giovannibajo at libero dot it
2005-01-26 10:25 ` pcarlini at suse dot de
2005-02-22  4:02 ` cvs-commit at gcc dot gnu dot org
2005-02-22  7:28 ` pcarlini at suse dot de

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).