This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB 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]

Re: representing C++ constructors in GDB's symbol tables


On Fri, 17 Sep 2004 17:45:40 -0500, Jim Blandy <jimb@redhat.com> said:

> It occured to me that perhaps constructors should not be in the
> VAR_DOMAIN.

This sounds plausible, though I'm not entirely convinced, but for what
it's worth this next claim of yours isn't really true:

> You can't use them by name in expressions: you have to say "new
> X(...)", never "X(...)".

You can use "X(...)" to create a temporary object of type X.  E.g. the
following program works fine.

  #include <iostream>

  class Printer {
    public:
      void print() const {
          std::cout << "print!\n";
      }
  };

  int main() {
      Printer().print();

      return 0;
  }

Having said that, a constructor really is a different beast from an
ordinary function call.  And I don't think that having GDB support

  (gdb) print Printer().print()

should be high on your list of priorities.

David Carlton
david.carlton@sun.com


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