This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17359] New: Can't convert function pointer


[Taken from http://gcc.gnu.org/ml/gcc/2004-09/msg00389.html] 
 
We can't compile this: 
---------------------- 
class B {}; 
 
struct D : public B { 
  template <int> void foo(); 
}; 
 
typedef void (B::*BfooPtr)(); 
typedef void (D::*fooPtr)(); 
 
void bar () { 
  static_cast<BfooPtr>(&D::foo<1>); 
  static_cast<BfooPtr>((fooPtr)&D::foo<1>); 
} 
---------------------------- 
 
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc 
x.cc: In function `void bar()': 
x.cc:11: error: invalid static_cast from type `<unknown type>' to type `void 
(B::*)()' 
 
Note that the first line with the static_cast fails, whereas the second one 
succeeds. This is wrong, since the cast in the second line only casts the 
member function pointer to exactly its type as before. 
 
gcc is also wrong, since the same code succeeds when foo() is not a template, 
and finally the error message with <unknown type> is really unhelpful: after 
all we completely resolved the overload set to a single function by 
specifying the template argument. 
 
W.

-- 
           Summary: Can't convert function pointer
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bangerth at dealii dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]