This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: How do I select a version of libstdc+ to link against?

> > Hi
> >
> > I am running Ubuntu 10.04, which has g++ 4.4 installed by default.  I want to
> > run g++ 4.1.3 so I installed 4.1.3 and set is as the default using update-
> > alternatives.  However, I suspect that although I am compiling with 4.1.3, I am
> > actually linking to libstdc+ 4.4.
> > Note that your issues have very little to do with the *development* of
> > libstdc++. Actually, I would say have little to do also with the *use*
> > of GCC as GCC, these are generic Unix / Linux questions, thus I'm not even
> > sure about recommending gcc-help instead.
> > How can I determine which version of libstdc+ I am linking against?
> > ldd on the executable, for example.
> > How can I select which version of libstdc+ to link against?

> LD_LIBRARY_PATH, for example.

Hi Paolo and Jonathan

Thanks for your replies.  I am sorry that my post was inappropriate for this list, but if I explain my problem further I think you will find some relevance.

Our C++ application uses the boolalpha manipulator with an istringstream object to read Boolean values from a string into a vector of strings. The code runs fine when compiled with g++ 4.1.2 on Centos 5.3, but another user reported that it failed when compiled with g++ 4.1.3 on Ubuntu 10.04.  I think that the failure is related to:

    gcc Bug 37958 - 'num_get<>::do_get(bool) sets eofbit flag incorrectly when boolalpha == true'

As far as I can see, this bug resulted in a change to libstdc++ 4.4.  If the Ubuntu case is using that library, that could explain the failure.

I can either ensure that the older version of libstdc++ is used, or I can modify the code so that it complies with the new behaviour of boolalpha.  The latter is preferable, as one day we should move to 4.4, so I would like to ask for some help to make the code change please.

Here is my test case:

Test case:

       cout << "start of test" << endl;

        std::istringstream iss("true true");
        vector<bool> myVect;
        bool b;
        while ( !iss.eof() )
            if ( ! )
                cout << "fail" << endl;
        cout << myVect.size() << endl;

        cout << "end of test" << endl;

Output on g++ 4.1.2 (Centos 5.3):

  start of test
  end of test

Output on g++ 4.1.3 (Ubuntu 10.04):

  start of test
  end of test

This means that the 4.1.3 case traversed the while loop 3 times. That is, eof() was not true after reading the second Boolean.  I really don't understand the discussion in the bug report but, for some reason, this behaviour seems to be what was required.  

I can fix the error but changing the while condition to:

    while ( iss.tellg() < iss.str().size() )

This seems a bit messy. Is there a better way?

Best regards


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]