[Bug c++/16209] New: Internal Compiler Error (ICE) Inheriting from std::vector

kmahler at ausafs dot ihost dot com gcc-bugzilla@gcc.gnu.org
Fri Jun 25 20:38:00 GMT 2004


I get an ICE with the following code:

// main_7.cc

#include <vector>

class A {
public:
  A(int input_a) : this_a(input_a) {}
  int this_a;
};

class B : public std::vector<A*> {};

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

  A my_A_1(1);
  A my_A_2(2);

  B my_B;

  my_B.push_back(&my_A_1);

  my_B.push_back(&my_A_2);

  A* my_A_ptr = my_B.std::vector::at(1);

  // main_7.cc: In function `int main(int, char **)':
  // main_7.cc:41: no matching function for call to `B::at (int)'
  // A* my_A_ptr = my_B.at(1);

  return(0);
}

***** end of file *****

If I replace "std::vector" with my own simple version, no ICE results:

// main_10.cc

//#include <vector>

template <class TYPE>
class table {
public:
  table() { next_index = 0; }
  void push_back(TYPE my_type) { array[next_index] = my_type; next_index++; }
  int size(void) { return(next_index); }
  TYPE& at(int specified_index) { return( array[specified_index] ); }
  TYPE array[10];
  int next_index;
};

class A {
public:
  A(int input_a) : this_a(input_a) {}
  int this_a;
};

class B : public table<A*> {};

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

  A my_A_1(1);
  A my_A_2(2);

  B my_B;

  my_B.push_back(&my_A_1);

  my_B.push_back(&my_A_2);

  A* my_A_ptr = my_B.at(1);

  return(0);
}

***** end of file *****

Also, in the first file, "main_7.cc", why does "A* my_A_ptr = my_B.at(1);" get 
a compile error and "A* my_A_ptr = my_B.std::vector::at(1);" does not.  

Yet, in the second file, "main_10.cc", "A* my_A_ptr = my_B.at(1);" compiles.

OS: SunOS 5.8
KernalID=Generic_108528-23

-- 
           Summary: Internal Compiler Error (ICE) Inheriting from
                    std::vector
           Product: gcc
           Version: 2.95.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kmahler at ausafs dot ihost dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16209



More information about the Gcc-bugs mailing list