bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

possible bug in gdb


From: Tom Kramer
Subject: possible bug in gdb
Date: Thu, 29 Nov 2001 12:29:35 -0500 (EST)

Hello GDB Bug -

I am using GDB 4.16 (sparc-sun-solaris2.5).

-----------------

If I put the following code in the file odd.cc and compile
it with the command "gcc -v -g -o odd odd.cc", it is compiled OK
and part of the verbiage it spews out while compiling is
"/depot/gnu/plat/lib/gcc-lib/sparc-sun-solaris2.6/2.7.2.1/cc1plus",
so apparently it is being compiled as C++.
When I run the "odd" executable, it runs OK.
But when I run "gdb odd" and do "ptype world", I get:

type = class world {
  public:
    strip cols[0];
    char thing[9];

    world(void);
    world(world const &);
    world & operator=(world const &);
}

Notice that the [0] above should be [9].
If I put a breakpoint in main then run the program, if I try
"print a_world", gdb gives me a segmentation fault.

If I compile with g++ instead of gcc, I get identical behavior.

----------------

If I put the same code in the file odd.c and compile it with the same
gcc command, it is compiled OK and part of the verbiage it spews out
while compiling is
"/depot/gnu/plat/lib/gcc-lib/sparc-sun-solaris2.6/2.7.2.1/cc1"
so apparently it is being compiled as C.
When I run the "odd" executable, it runs OK.
When I run "gdb odd", everything works OK; specifically:

When I do "ptype struct world", I get:

type = struct world {
    struct strip cols[9];
    char thing[9];
}

And, if I put a breakpoint in main then run the program, if I try
"print a_world", it works OK.

------------------

This may be a bug in gdb (or maybe I am not using gdb correctly or have
an outdated version).

Tom Kramer
address@hidden
*****************************************************************

#include <stdio.h>

struct strip
{
 int aim;
};

struct world
{
  struct strip cols[9];
  char thing[9];
};

main()
{
  struct world a_world;
  int n;

  for (n = 0; n < 9; n++)
    {
      a_world.cols[n].aim = n;
      a_world.thing[n] = ('a' + n);
    }
  for(n = 0; n < 9; n++)
    {
      printf("%d %c\n", a_world.cols[n].aim, a_world.thing[n]);
    }
}

****************************************************************




reply via email to

[Prev in Thread] Current Thread [Next in Thread]