This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/22265] Non -native type entry is getting added to an STL Map incorrectly
- From: "chris at bubblescope dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Jul 2005 09:47:42 -0000
- Subject: [Bug libstdc++/22265] Non -native type entry is getting added to an STL Map incorrectly
- References: <20050701030031.22265.kpbhat@sta.samsung.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From chris at bubblescope dot net 2005-07-01 09:47 -------
After a little thought (sorry, should have done it before), this bug all comes down to the order of
execution of function parameters, which I believe is undefined?
BTW, in case I wasn't clear enough in mail before, my belief now is that this is not a bug. There are two
fixes I can think of.
1) Only call inet_ntoa once per statement.
2) Wrap the return of inet_ntoa in string(), so the first thing you do when you get back the char* pointer
is copy the string it points to into a std::string. For example, your program works if I replace the nearly
last line with:
cout << "Key: " << string(inet_ntoa(itor->first.sin_addr))
<< ", " << itor->first.sin_port << endl
<< "Value: " << string(inet_ntoa(itor->second.sin_addr))
<< ", " << itor->second.sin_port << endl
<< endl;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22265