Boost logo

Boost :

Subject: Re: [boost] [polygon] compiled in MSVC8 successfully, but long long type gives runtime errors.
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2009-07-07 17:31:15


Simonson, Lucanus J wrote:
> Simonson, Lucanus J wrote:
>>> If your project has a similar level of SFINAE usage, I would think
>>> we could fix your code. I'm willing helping you out. Could you
>>> provide minimal code that shows your problem with MSVC9?
>>>

All code compiles and generally passes my unit tests in MSVC8.

It turns out that making the enable_if a default argument impacts regular overloading of functions and that adding a unique type into the enable_if logic to make all instantiations unique was a more reliable way to work around the compiler bugs.

I ran into a problem where boost::long_long_type isn't able to convert correctly to double. In the code below the return type of square_euclidean_distance is long long because I need twice as many bits to store the result of a multiply.

  euclidean_distance(const rectangle_type& lvalue, const rectangle_type_2& rvalue) {
        double val = (double)square_euclidean_distance(lvalue, rvalue);
    return sqrt(val);
  }

It fails a runtime check stating that val is left unitialized and in the debugger I can see that the value is indeed uninitialized. My question for any experts is why is this code failing?

I looking into the dissasembly and it looks like long long is 64 bit emulated in software in my 32 bit windows environment compiling with MSVC8. I couldn't find anywhere the conversion from long long to double, and it seems that it is just silently failing to provide it, leaving me with uninitialized data.

In MSVC8 BOOST_HAS_LONG_LONG is defined and I'm using the boost::long_long_type the way it was suggested that I should.

Thanks,
Luke


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk