Boost logo

Boost Users :

From: Colin Dewey (colin.dewey_at_[hidden])
Date: 2006-03-23 15:27:52


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<char, std::char_traits<char> >::init
() at test.cc:11
#3 0x0004b30c in boost::detail::lexical_stream<int,
std::string>::lexical_stream (this=0xbffff6f0) at
/usr/include/gcc/darwin/3.3-fast/c++/istream:98
#4 0x0004aed8 in boost::lexical_cast<int, std::string>
(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!


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net