Boost logo

Boost :

From: Joerg Walter (jhr.walter_at_[hidden])
Date: 2003-02-03 03:27:04

Hi Julius,

it looks as if your mail didn't find it's way to the boost ml. You wrote:

> Hello Joerg,
> and hello to whoever deals with MSVC .NET Standard conformance at boost:
> I found a small but nasty bug between MSVC .NET and ublas which I believe
> Microsoft's fault.
> #include <boost/numeric/ublas/iterator.hpp>
> #include <boost/numeric/ublas/traits.hpp>
> #include <iostream>
> int main()
> {
> std::cout <<
boost::numeric::ublas::type_traits<float>::abs( -10.2f ) << " "
> <<
 boost::numeric::ublas::type_traits<double>::abs( -10.2 );
> return 0;
> };
> gives me
> 10 10
> (not 10.2 10.2 as expected). The same code works fine with VC 6.0


> As fas as I can tell, the reason is:
> Unlike VC 6.0, VC .NET ships with the cstdlib header, where std::abs is
> However, the Microsoft folks basically just wrote
> namespace std{
> using ::abs;
> }
> in cstdlib so they have
> int abs( int )
> imported into namespace std from stdlib.h, while forgetting to add the
signatures float
> abs(float) and double abs(double) and so on as required by the Standard,

IIRC the signatures 'float abs(float)' and 'double abs(double)' should be
part of <cmath>, which is included in <ublas/traits.hpp>.

> Boost doesn't #define BOOST_NO_STDC_NAMESPACE in VC .NET, while in VC >
6.0 it is defined.
> Therefore, with VC .NET, ublas:.type_traits<>::abs uses int std::abs(int),
> converting the floats to integers and back.
> Joerg: I think you could use ::fabs for VC .NET in ublas just like you do
with VC 6.0,
> the signature is double ::fabs(double) and long doubles are doubles so
there is no round > off.

I'll do this, if we don't find a better workaround.

> Maybe #defining BOOST_NO_STDC_NAMESPACE for MSVC .NET is too
> drastic, but yes I think you need to do something about it. There may well
be other
> libraries in boost that would use
> std::abs if BOOST_NO_STDC_NAMESPACE is not defined.

That's what I think, too. Is there a known boost workaround for this



Boost list run by bdawes at, gregod at, cpdaniel at, john at