Modify

Opened 16 years ago

Closed 16 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).


Attachments (0)

Change History (2)

comment:1 Changed 16 years ago by jmaurer

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

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.)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain John Maddock.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.