[lexical_cast][STLport 4.5.3][trunk] static assertion failed in boost/detail/lcast_precision.hpp

Compiling the following snippet in MSVC++ 6.5 + STLport 4.5.3 with the trunk #include <boost/lexical_cast.hpp> int main() { return 0; } results in ...\boost\detail\lcast_precision.hpp(79) : error C2027: use of undefined type 'STATIC_ASSERTION_FAILURE<0>' ...\boost\detail\lcast_precision.hpp(89) : see reference to class template instantiation 'boost::detail::lcast_precision<T>' being compiled [...] The offending asserion in boost/detail/lcast_precision.hpp is BOOST_STATIC_ASSERT(!is_specialized_bin || limits::digits + 0UL < ULONG_MAX / 30103UL && precision_bin > limits::digits10 + 0UL && precision_bin <= streamsize_max + 0UL ); This problem did not arise with Boost 1.34 because boost/lexical_cast.hpp did not use the newly created lcast_precision.hpp. Other assertions in lcast_precision<> seem to work OK, so looks like is this particular one that should be fixed only. I lack the skills to propose a patch myself, but I can locally try patches others may provide. Thank you, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Joaquín Mª López Muñoz Sent: 08 October 2007 18:37 To: boost@lists.boost.org Subject: [boost] [lexical_cast][STLport 4.5.3][trunk] static assertion failed in boost/detail/lcast_precision.hpp
Compiling the following snippet in MSVC++ 6.5 + STLport 4.5.3 with the trunk
#include <boost/lexical_cast.hpp>
int main() { return 0; }
results in
...\boost\detail\lcast_precision.hpp(79) : error C2027: use of undefined type 'STATIC_ASSERTION_FAILURE<0>' ...\boost\detail\lcast_precision.hpp(89) : see reference to class template instantiation 'boost::detail::lcast_precision<T>' being compiled [...]
The offending asserion in boost/detail/lcast_precision.hpp is
BOOST_STATIC_ASSERT(!is_specialized_bin || limits::digits + 0UL < ULONG_MAX / 30103UL && precision_bin > limits::digits10 + 0UL && precision_bin <= streamsize_max + 0UL );
This problem did not arise with Boost 1.34 because boost/lexical_cast.hpp did not use the newly created lcast_precision.hpp. Other assertions in lcast_precision<> seem to work OK, so looks like is this particular one that should be fixed only. I lack the skills to propose a patch myself, but I can locally try patches others may provide.
Although I made some input on this, I'm not the maintainer for lexical_cast (and don't have thiese platforms to test). Maintainer is Alexander Nasonov [alexander.nasonov@gmail.com]) but in case he isn't listening: I can't see an obvious cause (presume it works OK on other platforms), so I can only suggest breaking this down into separate assertions to see which one is causing the trouble, and perhaps getting the values of std::limits<T>::digits and boost::is_abstract<T>. It seems that the suitable precision (decimal digits to use to get the full accuracy for type T) can't be calculated. It would also be useful to see what T is? Is this some funny type for which std::numeric_limits isn't properly specialised? HTH Paul --- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539561830 & SMS, Mobile +44 7714 330204 & SMS pbristow@hetp.u-net.com

Paul A Bristow ha escrito:
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Joaquín Mª López Muñoz Sent: 08 October 2007 18:37 To: boost@lists.boost.org Subject: [boost] [lexical_cast][STLport 4.5.3][trunk] static assertion failed in boost/detail/lcast_precision.hpp
Compiling the following snippet in MSVC++ 6.5 + STLport 4.5.3 with the trunk
#include <boost/lexical_cast.hpp>
int main() { return 0; }
results in
...\boost\detail\lcast_precision.hpp(79) : error C2027: use of undefined type 'STATIC_ASSERTION_FAILURE<0>' ...\boost\detail\lcast_precision.hpp(89) : see reference to class template instantiation 'boost::detail::lcast_precision<T>' being compiled
[...]
I can't see an obvious cause (presume it works OK on other platforms), so I can only suggest breaking this down into separate assertions to see which one is causing the trouble, and perhaps getting the values of std::limits<T>::digits and boost::is_abstract<T>.
It seems that the suitable precision (decimal digits to use to get the full accuracy for type T) can't be calculated.
It would also be useful to see what T is? Is this some funny type for which std::numeric_limits isn't properly specialised?
OK, I think I've got it: MSVC++ 6.5 behaves funny with static constants inside templates, as it does not see their correct value during template parsing. For instance, the following: #include <boost/config.hpp> #include <boost/static_assert.hpp> template<typename T> struct foo { BOOST_STATIC_CONSTANT(int,x=2); BOOST_STATIC_ASSERT(x==2); }; int main() { return 0; } fails at the static assertion line (x is seen as 1, btw). After instantiation, however, the static constant holds the correct value, this phenomenon only happens at the parsing stage. So, this is the problem with boost/detail/lcast_precision.hpp in MSVC++ 6.5 + STLport 4.5.3; when using the native Dinkumware stdlib the static assertions pass by pure chance, as they are affected by the same compiler bug. The attached diff simply omits the offending assertions for MSVC++ 6.0/7.0. Is it OK to commit? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo Index: lcast_precision.hpp =================================================================== --- lcast_precision.hpp (revision 39833) +++ lcast_precision.hpp (working copy) @@ -68,19 +68,23 @@ BOOST_STATIC_CONSTANT(unsigned int, precision_dec = limits::digits10 + 1U); +#if !defined(BOOST_MSVC)||!(BOOST_MSVC<1310) BOOST_STATIC_ASSERT(!is_specialized_dec || precision_dec <= streamsize_max + 0UL ); +#endif BOOST_STATIC_CONSTANT(unsigned long, precision_bin = 2UL + limits::digits * 30103UL / 100000UL ); +#if !defined(BOOST_MSVC)||!(BOOST_MSVC<1310) BOOST_STATIC_ASSERT(!is_specialized_bin || limits::digits + 0UL < ULONG_MAX / 30103UL && precision_bin > limits::digits10 + 0UL && precision_bin <= streamsize_max + 0UL ); +#endif BOOST_STATIC_CONSTANT(std::streamsize, value = is_specialized_bin ? precision_bin

Joaquín Mª López Muñoz <joaquin <at> tid.es> writes:
OK, I think I've got it: MSVC++ 6.5 behaves funny with static constants inside templates, as it does not see their correct value during template parsing. For instance, the following:
#include <boost/config.hpp> #include <boost/static_assert.hpp>
template<typename T> struct foo { BOOST_STATIC_CONSTANT(int,x=2); BOOST_STATIC_ASSERT(x==2); };
int main() { return 0; }
fails at the static assertion line (x is seen as 1, btw). After instantiation, however, the static constant holds the correct value, this phenomenon only happens at the parsing stage.
Does this change BOOST_STATIC_ASSERT(foo<T>::x==2); // qualified name help?
Is it OK to commit? I'd rather disabled compile-time calculation.
-- Alexander

Alexander Nasonov ha escrito:
JoaquÃn Mª López Muñoz <joaquin <at> tid.es> writes:
OK, I think I've got it: MSVC++ 6.5 behaves funny with static constants inside templates, as it does not see their correct value during template parsing. For instance, the following:
#include <boost/config.hpp> #include <boost/static_assert.hpp>
template<typename T> struct foo { BOOST_STATIC_CONSTANT(int,x=2); BOOST_STATIC_ASSERT(x==2); };
int main() { return 0; }
fails at the static assertion line (x is seen as 1, btw). After instantiation, however, the static constant holds the correct value, this phenomenon only happens at the parsing stage.
Does this change
BOOST_STATIC_ASSERT(foo<T>::x==2); // qualified name
help?
No, same assertion failure :(
Is it OK to commit? I'd rather disabled compile-time calculation.
The decision is yours to make, of course, but disabling the static assertions seems to suffice --the compile-time calculations are indeed OK and hold correct values once lcast_precision is instantiated. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Joaquín Mª López Muñoz Sent: 09 October 2007 09:35 To: boost@lists.boost.org Subject: Re: [boost] [lexical cast][STLport 4.5.3][trunk] static assertion failed in boost/detail/lcast precision.hpp
The decision is yours to make, of course, but disabling the static assertions seems to suffice --the compile-time calculations are indeed OK and hold correct values once lcast_precision is instantiated.
I hope we can selectively disable *only* for this aged (decrepit!) compiler. Paul

Joaquín Mª López Muñoz <joaquin <at> tid.es> writes:
The decision is yours to make, of course, but disabling the static assertions seems to suffice --the compile-time calculations are indeed OK and hold correct values once lcast_precision is instantiated.
My decision is based on the fact that your change ommits some checks while my suggestion just moves them to runtime. Though, these checks can be violated only if a user sets digits or digits10 to extrememly high value. -- Alexander

Alexander Nasonov ha escrito:
JoaquÃn Mª López Muñoz <joaquin <at> tid.es> writes:
The decision is yours to make, of course, but disabling the static assertions seems to suffice --the compile-time calculations are indeed OK and hold correct values once lcast_precision is instantiated.
My decision is based on the fact that your change ommits some checks while my suggestion just moves them to runtime. Though, these checks can be violated only if a user sets digits or digits10 to extrememly high value.
Yep, moving to runtime is defintely safer when viewed that way. Thank you for taking care of this! Contact me if you need some local testing before commiting the changes. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

I am trying to make the very first example in serialization work: http://www.boost.org/libs/serialization/doc/index.html (A Very Simple Case) I get linker errors about missing destructor : boost::archive::detail::basic_pointer_oserializer::~basic_pointer_oserializer(void) And similar errors. It seems the implementation of this destructor, which is declared in: boost/boost/archive/detail/basic_pointer_oserializer.hpp For some reason is implemented in: boost/libs/serialization/src/basic_pointer_oserializer.cpp The first obvious question is offcourse: Why is the implementation not under : boost/boost/archive/src/basic_pointer_oserializer.cpp ? Other questen is why is the "basic_pointer_oserializer.cpp" file not listed anywhere in the jamfiles? I can only find it in the vc71 solution provided in the serialization lib. I am aware that it might work if I use the official jambuilt libraries, but we really want to use our own Cmake files instead of Jam. I suppose I could just add the files like "basic_pointer_oserializer.cpp" to my Cmake files along with others that probably contains implemetations of other linker errors I get. Just its' still strange to me why they are not needed in the original jamfiles. -Martin Lutken

What version of boost are you using? Martin Lütken wrote:
I am trying to make the very first example in serialization work: http://www.boost.org/libs/serialization/doc/index.html (A Very Simple Case)
I get linker errors about missing destructor : boost::archive::detail::basic_pointer_oserializer::~basic_pointer_oserializer(void) And similar errors.
It seems the implementation of this destructor, which is declared in: boost/boost/archive/detail/basic_pointer_oserializer.hpp For some reason is implemented in: boost/libs/serialization/src/basic_pointer_oserializer.cpp
The first obvious question is offcourse: Why is the implementation not under : boost/boost/archive/src/basic_pointer_oserializer.cpp ?
Other questen is why is the "basic_pointer_oserializer.cpp" file not listed anywhere in the jamfiles? I can only find it in the vc71 solution provided in the serialization lib.
I am aware that it might work if I use the official jambuilt libraries, but we really want to use our own Cmake files instead of Jam. I suppose I could just add the files like "basic_pointer_oserializer.cpp" to my Cmake files along with others that probably contains implemetations of other linker errors I get. Just its' still strange to me why they are not needed in the original jamfiles.
-Martin Lutken _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Paul A Bristow <pbristow <at> hetp.u-net.com> writes:
Although I made some input on this, I'm not the maintainer for lexical_cast (and don't have thiese platforms to test).
Maintainer is Alexander Nasonov [alexander.nasonov <at> gmail.com]) but in case he isn't listening:
I'm listening but I couldn't reply last few times because gmane rejects to send my messages. Sorry to all who didn't get a reply. I don't have an access to this complier either.
I can't see an obvious cause (presume it works OK on other platforms), so I can only suggest breaking this down into separate assertions to see which one is causing the trouble, and perhaps getting the values of std::limits<T>::digits and boost::is_abstract<T>.
It seems that the suitable precision (decimal digits to use to get the full accuracy for type T) can't be calculated.
It would also be useful to see what T is? Is this some funny type for which std::numeric_limits isn't properly specialised?
There is no specialication at all in the example:
#include <boost/lexical_cast.hpp> int main() { return 0; }
Joaquín, can you try #include <boost/detail/lcast_precision.hpp> int main() {} and then break this assertion down to see which part is failing? If it doesn't help, you can disable precision calculation at compile-time. Currently, it's disabled only if BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS is defined but of course it can be changed. -- Alexander
participants (5)
-
Alexander Nasonov
-
Joaquín Mª López Muñoz
-
Martin Lütken
-
Paul A Bristow
-
Robert Ramey