Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STL bug in IBM AIX compiler?

Status
Not open for further replies.

clordaz

IS-IT--Management
Aug 30, 2002
1
US
The code:
#include <iostream>
#include <vector>
#include <deque>


// typedef std::vector<WORK_ORDER_STRU> Test_Vector;


void foo(const std::string p_s)
{
p_s = &quot;end&quot;;
}


int main()
{
std::string s = &quot;start&quot;;

std::cout << s << endl;

foo(s);

std::cout << s << endl;
}
The problem:
compiles and runs on Solaris 2.8, HPUX 11.0, RedHat Linux 8. Compiles but cores on AIX 4.3.3.11 and 5.2 with VisualAge C++ 5 and 6.
The same problem occurs with vector and deque, vector just takes longer. We've been developing this application on all platforms for about 10 years and this problem just started. I have cores, executables and backtraces if anyone is interested;they aren't too helpful but I'm personally sick of looking at them. Any help, ideas, interest would be greatly appreciated.
 
I think you must have copied it wrong because the posted code shouldn't compile on anything.

You should remember that if you are using std::string you must include <string>. In some implementations <string> is included inside of <iostream>, but on others it is not and you should never rely on it even if it works for you.

Also, why are you assigning a new value to a const variable? Does that really work on the platforms you mention? The following code should work anywhere:

Code:
#include <iostream>
#include <string>

void foo(std::string& p_s)
{
   p_s = &quot;end&quot;;
}

int main()
{
   std::string s = &quot;start&quot;;

   std::cout << s << std::endl;

   foo(s);

   std::cout << s << std::endl;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top