Re: [patch/testsuite/c++] test script for PR c++/186

Michael Elizabeth Chastain
2003-11-23T23:00:46Z

Well, you have a point. The gdb user is attempting to look at an object
after its last access from the source code. A C++ compiler has always
had the right to fool around with such memory (so does a C compiler;
gcc optimizes away local variables often).

A test script can only observe behavior. When gdb prints
"b1 = 12345678", the test script doesn't know if it's dealing with a
conforming compiler that scribbled on the memory, or a gdb bug that
causes gdb to print a value that is not in memory.

We kinda rely on compilers being simple. As compilers grow
more optimizations we get breakages like store.exp and have to fix them.
Imagine a bug-catching compiler that scribbles bait-patterns into dead
memory -- that would break this script.

Hmmm, my test would be more clear if I made B::~B write something into
the data fields. I will do that. And write some more comments about
this.

I will also add some tests like this:

A alpha;
...
(gdb) print (B *) &alpha;

I think that's actually the heart and these issues with destructors
and scope are peripheral. (But the destructor issue is interesting
because the program is doing something important in memory that is not
obvious to the programmer).

Michael C