This is the mail archive of the gdb-patches@sourceware.org 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: PR9167 Derived class static member CRTP infinite recursion on print


On 04/20/10 14:46, Tom Tromey wrote:
"Chris" == Chris Moller<cmoller@redhat.com> writes:

Chris> You can't do that. obstack_base() returns a pointer to the current Chris> allocation, which may change depending on what's stuffed into the Chris> obstack--by the time the obstack_free is hit, the base may have Chris> changed.

Why do we need to pop the stack at all?
It seems to me that if we printed something once, during a given call
into val_print, then we should never try to print it again.
Am I missing something?

You need the pop in situations like:


   class A
   {
        // whatever
   };

   class B
   {
        static A a1[] = ...;
        static A a2[] = ...;
   };

B b;

In this example, printing a1 of 'b' will stick class A on the stack--if you don't pop the stack, a2 won't be printed at all. What the stack does is record, at each stack level, what's been printed. In this case, without the use of the stack, printing the members of a1 would print A, which would print the members of a1, which would print A,...


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