[patch 1/3] Template Lookup

Tom Tromey tromey@redhat.com
Tue Aug 31 22:05:00 GMT 2010


>>>>> "Sami" == sami wagiaalla <swagiaal@redhat.com> writes:

Sami> Hmm.. can you give me an example of this ? I tried to construct an
Sami> example with an extern function but I learned that cplus does not
Sami> allow extern template functions.

Ordinarily, to make a test involving psymtab expansion, you have to make
two compilation units.

Put this into one file:

    template<typename T> double f (T x) { return x; }

    int g (void)
    {
      return f(1.0) + f(2);
    }

Put this in another file:

    extern int g(void);

    int main()
    {
      return g();
    }

Compile, debug, and "start".

Now in main:

    (gdb) p f(1.0)
    No symbol "f" in current context.
    (gdb) p f<double>(1.0)
    $1 = 1

... but if you step into g, it works:

    (gdb) s
    g () at q1.cc:5
    5	  return f(1.0) + f(2);
    (gdb) p f(1.0)
    $2 = 1

Tom> There are a couple instances of this that have to be updated in light of
Tom> Doug's recent change to how this is done.

Sami> What is the change that Doug made ?

He added various set_lang_ functions.
Maybe I'm mistaken about the need for this, as there doesn't seem to be
a special function for C++.

Tom



More information about the Gdb-patches mailing list