public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14248] New: Unable to call a templated member function in C++
@ 2012-06-15  9:27 thor at math dot tu-berlin.de
  2012-06-19 18:37 ` [Bug c++/14248] " tromey at redhat dot com
  0 siblings, 1 reply; 2+ messages in thread
From: thor at math dot tu-berlin.de @ 2012-06-15  9:27 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14248

             Bug #: 14248
           Summary: Unable to call a templated member function in C++
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@sourceware.org
        ReportedBy: thor@math.tu-berlin.de
    Classification: Unclassified
              Host: x86_64-linux-gnu
            Target: x86_64-linux-gnu
             Build: x86_64-linux-gnu


If a class contains templated member functions, these member functions are
found by gdb and are printed, but cannot be called.

Consider the following class:

class OpenCLBuffer {
  //
  // more stuff here...
  //
public:
  template<typename type> type Peek(unsigned int offset);
};

plus a proper implementation. For the sake of the argument, assume:

template<typename type>
type OpenCLBuffer::Peek(unsigned int offset)
{
return 0;
}
template unsigned char OpenCLBuffer::Peek<unsigned char>(unsigned int);

Using the TAB expansion of gdb shows that this method is actually known to gdb:

p OpenCLBuffer::Peek<un[TAB]

shows (amonst others):

unsigned char OpenCLBuffer::Peek<unsigned char>(unsigned int)

You can even show its address:

(gdb) p OpenCLBuffer::Peek<unsigned char>
$2 = {unsigned char (OpenCLBuffer * const, unsigned int)} 0x76e5be
<OpenCLBuffer::Peek<unsigned char>(unsigned int)>

However, trying to call it from gdb gives nothing:

(gdb) call m_pBuffer[0]->Peek<unsigned char>(0)
Couldn't find method OpenCLBuffer::Peek<unsigned char>

Bummer!

This is version 7.4.1 of gdb. Potentially, this is a duplicate of bug 9423, a
regression from a very old version of gdb.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug c++/14248] Unable to call a templated member function in C++
  2012-06-15  9:27 [Bug c++/14248] New: Unable to call a templated member function in C++ thor at math dot tu-berlin.de
@ 2012-06-19 18:37 ` tromey at redhat dot com
  0 siblings, 0 replies; 2+ messages in thread
From: tromey at redhat dot com @ 2012-06-19 18:37 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14248

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at redhat dot com

--- Comment #1 from Tom Tromey <tromey at redhat dot com> 2012-06-19 18:36:51 UTC ---
This works for me, using 7.4 and also cvs trunk:

(gdb) p m_pBuffer[0]->Peek<unsigned char>(0)
$1 = 0 '\000'
(gdb) show version
GNU gdb (GDB) 7.4.0.20120125-cvs


I wonder if this could be a compiler problem instead.
I'm using the Fedora 16 system gcc:

barimba. gcc --version
gcc (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2)

... 4.6 based but probably has plenty of backports.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

end of thread, other threads:[~2012-06-19 18:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-15  9:27 [Bug c++/14248] New: Unable to call a templated member function in C++ thor at math dot tu-berlin.de
2012-06-19 18:37 ` [Bug c++/14248] " tromey at redhat 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).