lexical_cast problem with OS X gcc -fast option

If I compile the following code (test.cc):
#include <iostream>
#include <string>
#include "boost/lexical_cast.hpp"
int main() {
int i;
std::string s("3");
try {
i = boost::lexical_cast<int>(s);
} catch (boost::bad_lexical_cast& e) {
std::cerr << "Error in conversion\n";
}
}
with the "-fast" and "-mcpu=G4" options for gcc 3.3 on MacOS X 10.4.5, like so:
g++ -I. -ggdb -fast -mcpu=G4 test.cc -o test
I get a Bus error when I run the compiled program. I do not get this
error when I omit the "-fast -mcpu=G4" options. Here is the trace
from gdb:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x00017d44 in std::locale::operator= () at test.cc:11
11 }
(gdb) backtrace
#0 0x00017d44 in std::locale::operator= () at test.cc:11
#1 0x00019e54 in std::ios_base::_M_init () at test.cc:11
#2 0x0001a8c0 in std::basic_ios

"Colin Dewey"
If I compile the following code (test.cc):
#include <iostream> #include <string>
#include "boost/lexical_cast.hpp"
int main() {
int i; std::string s("3");
try {
i = boost::lexical_cast<int>(s);
} catch (boost::bad_lexical_cast& e) { std::cerr << "Error in conversion\n"; } }
with the "-fast" and "-mcpu=G4" options for gcc 3.3 on MacOS X 10.4.5, like so:
g++ -I. -ggdb -fast -mcpu=G4 test.cc -o test
I get a Bus error when I run the compiled program. I do not get this error when I omit the "-fast -mcpu=G4" options. Here is the trace from gdb:
Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x00000000 0x00017d44 in std::locale::operator= () at test.cc:11 11 } (gdb) backtrace #0 0x00017d44 in std::locale::operator= () at test.cc:11 #1 0x00019e54 in std::ios_base::_M_init () at test.cc:11 #2 0x0001a8c0 in std::basic_ios
::init () at test.cc:11 #3 0x0004b30c in boost::detail::lexical_stream ::lexical_stream (this=0xbffff6f0) at /usr/include/gcc/darwin/3.3-fast/c++/istream:98 #4 0x0004aed8 in boost::lexical_cast (arg=@0xbffff9e0) at boost/lexical_cast.hpp:135 #5 0x000028e8 in main () at test.cc:10 Any help with this would be greatly appreciated. Thanks!
This is almost certainly a compiler bug that should be reported to the GCC developers. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
Colin Dewey
-
David Abrahams