This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


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

c++/3359: Struct.C:16: Internal compiler error.



>Number:         3359
>Category:       c++
>Synopsis:       Struct.C:16: Internal compiler error.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 22 04:36:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Graziano Vello
>Release:        2.95.3 20010315 (release) (i686-pc-linux-gnu)
>Organization:
>Environment:
Linux Kernel 2.2.17 (SuSE 7.0)
>Description:
Struct.C: In function `class istream & read(istream &, MyStructure &)':
Struct.C:16: Internal compiler error.
Struct.C:16: Please submit a full bug report.
Struct.C:16: See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
>How-To-Repeat:
simply g++ Struct.C
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="Struct.C"
Content-Disposition: inline; filename="Struct.C"

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

// This is my very first structure :)
//
struct MyStructure {
  string name;
  vector<int> SomeInts;
};

istream& read(istream& GVInput, MyStructure& s)
{
  GVInput >> s.name;
  read_vector(GVInput, s.vector);
  return Input;
}

istream& read_vector(istream& Input, vector<int>& InVec)
{
  if (Input) {
    // clear previous content, if any
    InVec.clear();
    int Num;
    while (Input >> Num)
      {
	InVec.push_back(Num);
      }
    // clear the istream for the next input
    //
    Input.clear();
  }
  return Input;
}

bool cmp_struct (const MyStructure& St1, const MyStructure& St2)
{
  return St1.name < St2.name;
}

int main()
{
  vector<MyStrucure> Structures;
  MyStructure InStruct;
  string::size_type maxlen = 0;
  //
  // getting the structures...
  //
  while(read(cin, InStruct))
    {
      maxlen = max(maxlen, Instruct.name.size());
      Structures.push_back(InStruct);
      sort(Structures,begin(), Structures.end(), cmp_struct);
      for (vector<MyStructure>::size_type i = 0;
	   i != Structures.size(); i++) {
	cout << "Name: " <<  setw(maxlen+1) << Structures[i].name << endl;
      }
    }
  return 0;
}


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