M
mlm
Hi,
I believe that it should not be legal to create a vector (and array) of
stringstream since the copy constructor and assignment operators are
declared private. However, I don't understand why it shouldn't be
legal to create a vector (or array) or stringstream pointers. The
following code compiles and runs on g++, but seg faults while using the
Intel c++ compiler. Is this standard code? Which newsgroup (intel or
g++) needs to be consulted?
=============================================================
g++ -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)
==============================================================
Intel C++ compiler version 8.1
==============================================================
#include <vector>
#include <sstream>
#include <iostream>
using namespace std;
int main()
{
int test1 = 100;
int test2 = 200;
vector<stringstream*> ssv;
for(int i=0; i<10; i++)
ssv.push_back(new stringstream);
cout << "test1: " << test1 << endl;
cout << "test2: " << test2 << endl;
for(int i=0; i<10; i++) {
*ssv << "testing 1 2 3" << endl;
}
cout << "test1: " << test1 << endl;
cout << "test2: " << test2 << endl;
for(int i=0; i<10; i++) {
cout << ssv->str() << endl;
cout << "test1: " << test1 << endl;
cout << "test2: " << test2 << endl;
}
return 0;
}
[ btw - while debugging this problem I noticed that local variables
declared at the top of method are being overwritten. If you use the
Intel compiler, you'll start to see that test1 and test2 will contain
garabage after a few iterations through the last for loop. And this is
another question - why would anything that is happening in the last for
loop cause _anything_ to be overwritten? ]
Thanks,
mlm
I believe that it should not be legal to create a vector (and array) of
stringstream since the copy constructor and assignment operators are
declared private. However, I don't understand why it shouldn't be
legal to create a vector (or array) or stringstream pointers. The
following code compiles and runs on g++, but seg faults while using the
Intel c++ compiler. Is this standard code? Which newsgroup (intel or
g++) needs to be consulted?
=============================================================
g++ -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)
==============================================================
Intel C++ compiler version 8.1
==============================================================
#include <vector>
#include <sstream>
#include <iostream>
using namespace std;
int main()
{
int test1 = 100;
int test2 = 200;
vector<stringstream*> ssv;
for(int i=0; i<10; i++)
ssv.push_back(new stringstream);
cout << "test1: " << test1 << endl;
cout << "test2: " << test2 << endl;
for(int i=0; i<10; i++) {
*ssv << "testing 1 2 3" << endl;
}
cout << "test1: " << test1 << endl;
cout << "test2: " << test2 << endl;
for(int i=0; i<10; i++) {
cout << ssv->str() << endl;
cout << "test1: " << test1 << endl;
cout << "test2: " << test2 << endl;
}
return 0;
}
[ btw - while debugging this problem I noticed that local variables
declared at the top of method are being overwritten. If you use the
Intel compiler, you'll start to see that test1 and test2 will contain
garabage after a few iterations through the last for loop. And this is
another question - why would anything that is happening in the last for
loop cause _anything_ to be overwritten? ]
Thanks,
mlm