Opened 17 years ago

Closed 17 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:


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 

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

The same header included boost header 

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.


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

Change History (2)

comment:1 Changed 17 years ago by jmaurer

Logged In: YES 

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 Changed 17 years ago by jmaurer

Status: assignedclosed
Logged In: YES 

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.