public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17359] New: Can't convert function pointer
@ 2004-09-08 21:03 bangerth at dealii dot org
  2004-09-09  6:52 ` [Bug c++/17359] " simartin at users dot sourceforge dot net
  2004-09-09 10:01 ` giovannibajo at libero dot it
  0 siblings, 2 replies; 6+ messages in thread
From: bangerth at dealii dot org @ 2004-09-08 21:03 UTC (permalink / raw)
  To: gcc-bugs

[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


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

end of thread, other threads:[~2009-12-26 12:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-17359-102@http.gcc.gnu.org/bugzilla/>
2006-09-25 19:38 ` [Bug c++/17359] Can't convert function pointer pinskia at gcc dot gnu dot org
2007-01-21  5:23 ` bangerth at dealii dot org
2009-04-16 18:07 ` pinskia at gcc dot gnu dot org
2009-12-26 12:44 ` paolo dot carlini at oracle dot com
2004-09-08 21:03 [Bug c++/17359] New: " bangerth at dealii dot org
2004-09-09  6:52 ` [Bug c++/17359] " simartin at users dot sourceforge dot net
2004-09-09 10:01 ` giovannibajo at libero dot it

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