C++ Debug builds broke in Snow Leopard Xcode

后端 未结 3 1460
日久生厌
日久生厌 2020-12-03 08:33

After upgrading to Xcode 3.2 and Snow Leopard, my debug builds are broken and fail at runtime. Stringstreams do not seem to work. They work in Release mode.

I\'ve

3条回答
  •  旧巷少年郎
    2020-12-03 09:25

    This is now a known and reported bug in the compiler. The only workarounds are:

    1. Remove the flags as you suggested. This is okay, but those flags are very useful at times, and you don't want to remove them from projects and after the bug is fixed go back and update them again!

    2. Execute in release mode for testing until you really need the debugger symbols and then temporarily remove the flags.

    I have opted for #2 so that when the fix comes out, but projects are not missing the flags. For more information see:

    Apple Discussions

    BTW, the code the that I had that had this problem was just this simple:

    #include 
    #include 
    
    using namespace std;
    
    int main() {
        string firstName;
        string lastName;
        int age;
        char gender;
    
        cout << "Enter First Name: " << endl;
        cin >> firstName;  // <----- error happens right here
    
        cout << "Enter Last Name: ";
        cin >> lastName;
    
        cout << "Enter age: ";
        cin >> age;
    
        cout << "Enter gender: (m or f) ";
        cin >> gender;
    
        cout << firstName << lastName << age << gender;
    
        return 0;
    }
    

提交回复
热议问题