Cannot subscript vector<vector<T> > in gdb if use typedefs

fago@caltech.edu fago@caltech.edu
Thu Sep 9 17:44:00 GMT 2004


I am having a problem accessing the members of objects of the type
vector< vector< T > > if typedefs are used. See below for details.

I could not find anything related in the bug database. The problem may
be related to the thread:
  http://sources.redhat.com/ml/gdb/2004-08/msg00265.html
except that reverting back to gcc 3.3.4 did not fix the issue.

Not sure if this is GCC or GDB, but thought I'd start here...

Thanks,
Matt


Test case and more details:

// gcc 3.4.2 (and 3.3.4), gdb 6.2.1, RHEL 3.0 ix86. Compile via:
//
// g++ -ggdb -o test main.cc
//
// In gdb, "p a[5][5]" results in:
//
//   cannot subscript something of type \
//   `std::vector<double,std::allocator<double> >'
//
// Removing DoubleVector and DoubleMatrix typedefs 
//    --> "p a1[5][5]" works

#include <vector>
#include <iostream>

typedef std::vector<double> DoubleVector;
typedef std::vector<DoubleVector > DoubleMatrix;
typedef std::vector< std::vector<double> > DM;

int main(int argc, char** argv) {

  DoubleVector  v(6);
  DoubleMatrix  a( 6, DoubleVector(6) );
  DM           a1( 6, std::vector<double>(6) );
  std::cout << v[5] << a[5][5] << a1[5][5] << std::endl;
  
  return 0;
}









More information about the Gdb mailing list