Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#6441 closed Bugs (fixed)

lexical_cast uses non existing std::basic_stringstream<char>::pptr when compiling with -DBOOST_NO_STD_LOCALE

Reported by: leutloff@… Owned by: Antony Polukhin
Milestone: Boost 1.50.0 Component: lexical_cast
Version: Boost 1.48.0 Severity: Regression
Keywords: Cc: antoshkka@…

Description

BOOST_NO_STD_LOCALE is handled in this context:

#if defined(BOOST_NO_STRINGSTREAM)
            typedef stl_buf_unlocker<std::strstream, CharT > local_stringbuffer_t;
#elif defined(BOOST_NO_STD_LOCALE)
            typedef stl_buf_unlocker<std::stringstream, CharT > local_stringbuffer_t;
#else
            typedef stl_buf_unlocker<std::basic_stringbuf<CharT, Traits>, CharT > local_stringbuffer_t;
#endif

but the stl_buf_unlocker class is using missing methods (pptr, pbase, setg, setp):

    namespace detail // stl_buf_unlocker
    {
        template< class BufferType, class CharT >
        class stl_buf_unlocker: public BufferType{
        public:
            typedef BufferType base_class;
#ifndef BOOST_NO_USING_TEMPLATE
            using base_class::pptr;
            using base_class::pbase;
            using base_class::setg;
            using base_class::setp;
#else
            CharT* pptr() const { return base_class::pptr(); }
            CharT* pbase() const { return base_class::pbase(); }
            void setg(CharT* gbeg, CharT* gnext, CharT* gend){ return base_class::setg(gbeg, gnext, gend); }
            void setp(CharT* pbeg, CharT* pend) { return setp(pbeg, pend); }
#endif
        };
    }

These are the errors from the compiler:

./boost/lexical_cast.hpp:1129:31: error: no members matching ‘boost::detail::stl_buf_unlocker<std::basic_stringstream<char>, char>::base_class {aka std::basic_stringstream<char>}::pptr’ in ‘boost::detail::stl_buf_unlocker<std::basic_stringstream<char>, char>::base_class {aka struct std::basic_stringstream<char>}’
./boost/lexical_cast.hpp:1130:31: error: no members matching ‘boost::detail::stl_buf_unlocker<std::basic_stringstream<char>, char>::base_class {aka std::basic_stringstream<char>}::pbase’ in ‘boost::detail::stl_buf_unlocker<std::basic_stringstream<char>, char>::base_class {aka struct std::basic_stringstream<char>}’
./boost/lexical_cast.hpp:1131:31: error: no members matching ‘boost::detail::stl_buf_unlocker<std::basic_stringstream<char>, char>::base_class {aka std::basic_stringstream<char>}::setg’ in ‘boost::detail::stl_buf_unlocker<std::basic_stringstream<char>, char>::base_class {aka struct std::basic_stringstream<char>}’
./boost/lexical_cast.hpp:1132:31: error: no members matching ‘boost::detail::stl_buf_unlocker<std::basic_stringstream<char>, char>::base_class {aka std::basic_stringstream<char>}::setp’ in ‘boost::detail::stl_buf_unlocker<std::basic_stringstream<char>, char>::base_class {aka struct std::basic_stringstream<char>}’

Compiling Boost.Test results in some more errors around this problem. I will attach the complete build log when building Boost.Test to show the compiler flags, too.

The error is present in 1.48 and trunk. The log is from the trunk build.

Attachments (1)

error-trunk.log (41.8 KB ) - added by leutloff@… 11 years ago.

Download all attachments as: .zip

Change History (11)

by leutloff@…, 11 years ago

Attachment: error-trunk.log added

comment:1 by John Maddock, 11 years ago

Owner: changed from nasonov to Antony Polukhin

comment:2 by Antony Polukhin, 11 years ago

I`ve successfully compiled and run some tests with all combinations of flags BOOST_NO_STRINGSTREAM and BOOST_NO_STD_LOCALE. No errors. I used gcc-4.6.1, just as you did.

Looks like you have bad installation of GCCs STL headers.

Please support more info, so I could reproduce this bug.

comment:3 by leutloff@…, 11 years ago

Hmm, I am puzzled.

Here are some more information. I am trying to build on two different 64 bit systems. An up to date Ubuntu and a legacy Debian Lenny system. The legacy Debian system is the reason to use BOOST_NO_STD_LOCALE. But this old system is unfortunately my target system 8-(

Okay, here are my findings, starting with the Ubuntu system (Ubuntu 11.10 (GNU/Linux 3.0.0-16-generic x86_64)):

Compiling svn trunk (revision r76903, 2012-02-05):

  • cd boost-trunk
  • (./bootstrap.sh)
  • ./b2 clean
  • ./b2 toolset=gcc cxxflags=-DBOOST_NO_STD_LOCALE --with-test stage

GCC version (gcc --version):

These are the installed STL headers (dpkg -l '*stdc++*-dev'):

  • libstdc++6-4.6-dev, 4.6.1-9ubuntu3, GNU Standard C++ Library v3 (development files)

This is the only installed libstdc++. (There was an old one installed, but I have removed it and tried again.)

Now switching to ancient Debian Lenny system. But the outcome is the same.

Executing again:

  • ./b2 clean
  • ./b2 toolset=gcc cxxflags=-DBOOST_NO_STD_LOCALE --with-test stage

GCC version (gcc --version):

  • gcc (Debian 4.3.2-1.1) 4.3.2

These are the installed STL headers (dpkg -l '*stdc++*-dev'):

  • libstdc++6-4.3-dev, 4.3.2-1.1

I have no idea what the problem is. So I searched the web for char_type unexpected differences on 32 and 64 bit systems. I have included sstream in libs/test/src/logged_expectations.cpp, but nothing changed (on the Ubuntu system). Any pointers to solve this behavior are greatly appreciated.

in reply to:  3 comment:4 by Antony Polukhin, 11 years ago

Replying to leutloff@…:

Here are some more information. I am trying to build on two different 64 bit systems. An up to date Ubuntu and a legacy Debian Lenny system. The legacy Debian system is the reason to use BOOST_NO_STD_LOCALE. But this old system is unfortunately my target system 8-(

BOOST_NO_STD_LOCALE is an internal define, that describes STL library defects. It must be set up by boost/config.hpp. I don`t think that BOOST_NO_STD_LOCALE is meant to be used this way.

Why are you explicitly specifying it?

comment:5 by leutloff@…, 11 years ago

Why are you explicitly specifying it?

std::locale("") throws an exception on the old system (libstdc++6, 4.3.2). Therefore I must ensure that locale is not instantiated. Defining BOOST_NO_STD_LOCALE avoided the exception for some of the boost libraries I am using (I suppose it was thread and regex). I have read that defining BOOST_NO_STD_LOCALE is the correct way to avoid the std::locale instantiation. But I can not find the documents for reference at the moment 8-(

comment:6 by Antony Polukhin, 11 years ago

Cc: antoshkka@… added
Milestone: To Be DeterminedBoost 1.50.0
Status: newassigned

I`ve reproduced the error.
Thanks for bug report and additional info!

comment:7 by Antony Polukhin, 11 years ago

Resolution: fixed
Status: assignedclosed

(In [77077]) Fixes #6441 (compilation error with BOOST_NO_STD_LOCALE defined)

comment:8 by Antony Polukhin, 11 years ago

Now it compiles with BOOST_NO_STD_LOCALE, but I think that your error can occur at any time: all the STL streams use std::locale. May be a better solution in your case would be to update GCC.

comment:9 by leutloff@…, 11 years ago

Thanks a lot for fixing this issue! I wish I could change GCC - I would have done it instead of writing this issue - BUT there is no way for me to change it 8-(

comment:10 by Antony Polukhin, 11 years ago

(In [77117]) Update for fixed #6441 (unable to compile lexical_cast with BOOST_NO_STD_LOCALE defined) Now test must compile under VC, removed some warnings.

Note: See TracTickets for help on using tickets.