Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#3410 closed Bugs (fixed)

Warnings in Boost::function when compiled with "-Wold-style-cast"

Reported by: c-rom ( -at- ) gmx . de Owned by: Douglas Gregor
Milestone: Boost 1.41.0 Component: function
Version: Boost 1.40.0 Severity: Cosmetic
Keywords: old-style-cast Cc:


Boost::function reports warnings when compiled with "-Wold-style-cast".

There are several old style casts left (besides many "new style casts", so this might be harmonized) in files:



Please see ticket #2983 which is very similar to this one.

The following code example reproduces the issue with Boost 1.40:



#include <iostream>

#include <boost/function.hpp>

struct add


int operator()( int arg1, int arg2 )


return ( arg1 + arg2 );



int main( int argc, char argv )


boost::function<int ( int, int )> f;

f = add();

std::cout << f( 2, 2 ) << std::endl;

return 0;



The piece of code for this bug report has been compiled with g++ (GCC) 3.4.3:

g++ -Wold-style-cast -o Example -I<PATH_TO_BOOST> Example.cpp

Attachments (0)

Change History (2)

comment:1 Changed 7 years ago by Jeremiah Willcock

Resolution: fixed
Status: newclosed

(In [62614]) Removed all but one old-style cast, breaking GCC 2.95.3; fixes #3410

comment:2 Changed 7 years ago by Daniel James

(In [70361]) Function: Merge from trunk.

  • Remove extra definition of operator(), since it's inline anyway. Fixes #4765.
  • Make sure that the cv flags are copied when we copy a reference to a function object. Fixes #4325
  • Fully qualified function calls to avoid ambiguity with new additions to standard. Thanks to Conrad Poelman. Fixes #4073
  • Remove iterator workaround for newer versions of Visual Age C++. Thanks to 'ccambly'. Fixes #3912
  • Fix unused variable warning for Visual C++. Fixes #3618
  • Testing flag for Visual C++.
  • Removed all but one old-style cast, prevents GCC warnings, but breaks GCC 2.95.3. Fixes #3410
  • Fixed tab and newline issues from inspection report.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Douglas Gregor.
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.