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]

[rfc] xfailed tests in gdb.c++/classes.exp


I've been looking at the xfailed tests in gdb.c++/classes.exp, and
some of the xfails aren't too convincing.  Specifically, the tests
that I'm looking at do ptypes of C++ data structures, and several of
the xfails fall into one or both of these categories:

1) GDB prints "class X { public: ... }" when the programmer originally
   wrote "struct X { ... }".

2) GDB prints "class X { private: int x; ... }" when the programmer
   originally wrote "class X { int x; ... }".

My question is: should we consider these as GDB bugs, or not?  In
other words, should I change the xfails to kfails, or should I change
them to passes?

The arguments for treating them as passes is as follows: GDB's goal
isn't to print out exactly what the programmer typed: it's to print
out a type that's equivalent to what the programmer typed, one that
gives all the information that the programmer needs.  So it would be
ridiculous, for example, to call it a bug in GDB if GDB didn't exactly
replicate the whitespace in a definition.  And, in both of the cases
above, programmers could replace their definitions by the definitions
that GDB prints out without changing the behavior of their programs.
Stroustrup says: "By definition, a struct is a class in which members
are by default public"; and just because members of a class are, by
default, private doesn't mean that there's anything wrong with making
that default explicit.

The arguments for treating them as failures are that DWARF 2 does, in
fact, contain enough information to be able to recover the data that
we're ignoring.  (GCC doesn't emit it, at least in case 1, but never
mind that.)  And, while changing all instances of "struct X { ... }"
to "class X { public: ... }" is behavior-preserving, changing one
instance might violate the one definition rule, so the two versions
aren't really the same for sufficiently pedantic definitions of "the
same".

Personally, I'd treat both these cases as passes.  On the other hand,
Daniel's the C++ maintainer; if he thinks one or both of these cases
should be considered a bug in GDB, then I'll file PR's and KFAIL them
as appropriate.

Opinions?

David Carlton
carlton@math.stanford.edu


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