Opened 13 years ago

Last modified 13 years ago

#3675 new Bugs

Boost.Parameter passing function pointers

Reported by: Aristid Breitkreuz <aristid.breitkreuz@…> Owned by: Daniel Wallin
Milestone: Boost 1.42.0 Component: parameter
Version: Boost 1.41.0 Severity: Problem
Keywords: Cc:

Description

When passing function pointers with Boost.Parameter on Boost 1.41 on MacPorts, there are errors.

Apparently, somewhere the function type gets a "const" and that breaks stuff.

That's the error message:

bash-3.2$ make CXXFLAGS=-I/opt/local/include test
g++ -I/opt/local/include    test.cc   -o test
/opt/local/include/boost/parameter/aux_/arg_list.hpp: In constructor 'boost::parameter::aux::arg_list<TaggedArg, Next>::arg_list(A0&, A1&, A2&, A3&, A4&) [with A0 = void ()(int)const, A1 = boost::parameter::void_, A2 = boost::parameter::void_, A3 = boost::parameter::void_, A4 = boost::parameter::void_, TaggedArg = boost::parameter::aux::tagged_argument<tag::par, void ()(int)>, Next = boost::parameter::aux::empty_arg_list]':
/opt/local/include/boost/parameter/parameters.hpp:876:   instantiated from 'typename boost::mpl::first<typename boost::parameter::aux::make_arg_list<boost::parameter::aux::item<PS0, A0, boost::parameter::void_>, typename boost::parameter::aux::make_deduced_items<PS0, boost::parameter::aux::make_deduced_items<PS1, boost::parameter::aux::make_deduced_items<PS2, boost::parameter::aux::make_deduced_items<PS3, boost::parameter::aux::make_deduced_items<PS4, boost::mpl::identity<boost::parameter::void_> > > > > >::type, boost::parameter::aux::tag_keyword_arg, mpl_::bool_<true> >::type>::type boost::parameter::parameters<PS0, PS1, PS2, PS3, PS4>::operator()(A0&) const [with A0 = void ()(int)const, PS0 = boost::parameter::required<tag::par, boost::mpl::always<mpl_::true_> >, PS1 = boost::parameter::void_, PS2 = boost::parameter::void_, PS3 = boost::parameter::void_, PS4 = boost::parameter::void_]'
test.cc:9:   instantiated from 'typename boost_param_result_14testfn<typename boost::parameter::aux::argument_pack<boost_param_parameters_14testfn, const ParameterArgumentType0, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::type>::type testfn(const ParameterArgumentType0&, typename boost::parameter::aux::match<boost_param_parameters_14testfn, ParameterArgumentType0, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::type) [with ParameterArgumentType0 = void ()(int)]'
test.cc:20:   instantiated from here
/opt/local/include/boost/parameter/aux_/arg_list.hpp:208: error: no matching function for call to 'boost::parameter::aux::tagged_argument<tag::par, void ()(int)>::tagged_argument(void (&)(int)const)'
/opt/local/include/boost/parameter/aux_/tagged_argument.hpp:37: note: candidates are: boost::parameter::aux::tagged_argument<KW, T>::tagged_argument(Arg&) [with Keyword = tag::par, Arg = void ()(int)]
/opt/local/include/boost/parameter/aux_/tagged_argument.hpp:32: note:                 boost::parameter::aux::tagged_argument<tag::par, void ()(int)>::tagged_argument(const boost::parameter::aux::tagged_argument<tag::par, void ()(int)>&)
make: *** [test] Error 1
bash-3.2$

The example compiles on Linux just fine. I will attach the example if I find out how to do it.

Please provide a workaround for the time until the fix for this hits the shelves.

Attachments (1)

boost-bug.cpp (290 bytes ) - added by Aristid Breitkreuz <aristid.breitkreuz@…> 13 years ago.
Code that SHOULD work on all platforms, but doesn't

Download all attachments as: .zip

Change History (3)

by Aristid Breitkreuz <aristid.breitkreuz@…>, 13 years ago

Attachment: boost-bug.cpp added

Code that SHOULD work on all platforms, but doesn't

comment:1 by wes@…, 13 years ago

System Info where bug was replicated:

  • Mac Ports 1.8.1 (latest)
  • Leopard, Intel iMac
  • i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)
  • Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386

comment:2 by ash.berlin@…, 13 years ago

The seems to be a bug of sorts in Apple's G++ 4.0.1. G++ 4.2.1 (which comes with xcode 3.1.3 and up) works.

Also it works if you change:

  std::cout << (testfn(f) == f) << std::endl;

to use &f instead of f:

  std::cout << (testfn(&f) == f) << std::endl;

It compiles and prints 1 as expected.

Note: See TracTickets for help on using tickets.