Opened 21 years ago

Closed 21 years ago

#29 closed Bugs (Fixed)

Visual C++ and min/max specialization

Reported by: nobody Owned by: John Maddock
Milestone: Component: None
Version: None Severity:
Keywords: Cc:

Description

Boost's default configuration for Visual C++ 6.0 
exposes some problems with the Visual C++ compiler 
when using min/max. (Boost version 1.26)

I had setup a header to expose min/max template 
functions instead of using the min/max macros in 
stdlib.h:

using std::min;
using std::max;

The same header included boost header 
(boost/operatiors.hpp)

The problem: If I mixed types in the min/max call, 
Visual C++ would always call the specialized min/max 
function for the long type given in suffix.hpp.

E.g.

float y = min( (double)a, (float)b );  
    //call boost's min(long,long)!!!!

I'm not sure why you have the specialization of 
min/max for long types in suffix.hpp, but from my 
perspective its more dangerous than it is useful. 

Without this template specialization, at least the 
compiler tells me that no version of min matches min
(double,float).


Change History (2)

comment:1 by jmaurer, 21 years ago

Logged In: YES 
user_id=53943

First, it's not a specialization, it's an overload.

It looks like some MSVC headers or program expect the
min/max macro behaviour, where you can mix types freely.  

I agree it changes semantics silently.  I've forwarded this
to John Maddock, our config guy.

comment:2 by jmaurer, 21 years ago

Status: assignedclosed
Logged In: YES 
user_id=53943

Temporarily fixed by adding a "long double" overload, until
proven that the "long" overload is actually never needed.
(Then all overloads can be removed together.)
Note: See TracTickets for help on using tickets.