Ticket #9153 (closed Bugs: fixed)

Opened 2 years ago

Last modified 2 years ago

Building boost::log in Sun Studio 12.3: boost::log::aux::light_function fails to build

Reported by: Brian Vandenberg <phantall+boost@…> Owned by: andysem
Milestone: To Be Determined Component: log
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc: phantall+boost@…


I get an error building boost::log in Sun Studio 12.3, while building anything that uses light_function_pp.hpp:

"./boost/log/detail/light_function_pp.hpp", line 44: Error: Multiple declaration for impl.
"./boost/log/expressions/filter.hpp", line 58:     Where: While specializing "boost::log::v2_mt_posix::aux::light_function<bool(const boost::log::v2_mt_posix::attribute_value_set&)>".
"./boost/log/expressions/filter.hpp", line 58:     Where: Specialized in non-template code.

I can reproduce this problem on a much smaller scale:

template < typename SignatureT >
class light_function ;

template < typename ResultT, typename ArgT0 >
class light_function < ResultT ( ArgT0 ) > {
  struct impl_base {};
  impl_base *m_pImpl;

#if defined( BREAK_IT )
  template < typename FunT >
  class impl;
  template < typename FunT >
  friend class impl;

  template < typename FunT >
  class impl : public impl_base {};

#if !defined( BREAK_IT )
  template < typename FunT >
  friend class impl;

  template <typename T>
  light_function( T const &t ) : m_pImpl( static_cast<impl_base*)new impl<T>() ) {}

int main( int argc, char *argv[] ) {
  light_function<bool(int&)> lf(3);

  return 0;

When compiled in Linux or Solaris with SS12.3, I get the exact same error.


Change History

comment:1 Changed 2 years ago by Brian Vandenberg <phantall+boost@…>

I forgot to mention, though I hope it's obvious: compile with -DBREAK_IT to see the problem.

comment:2 Changed 2 years ago by Brian Vandenberg <phantall+boost@…>

As for the 'why' of this, I'm not really sure. The attribute_set and attribute_value_set classes (among others) use this idiom of forward declaring a class before marking it as a friend class.

I tried using some compiler options to force it to only use explicitly specialized versions of the class and the error wouldn't go away.

comment:3 Changed 2 years ago by andysem

Unfortunately, I don't have access to this compiler, neither there are testers using it in the test farm. So the only way I can fix this is if you provide a patch or through some experiments to figure out the source of the problem.

Could you try to move impl definition out of light_function body?

comment:4 Changed 2 years ago by Brian Vandenberg <phantall+boost@…>


If you remove the forward declaration for impl and move the friend statement to after the impl body, the error goes away.

comment:5 Changed 2 years ago by Brian Vandenberg <phantall+boost@…>

  • Cc phantall+boost@… added

comment:6 Changed 2 years ago by andysem

Does it help if you just define BOOST_LOG_NO_MEMBER_TEMPLATE_FRIENDS macro?

comment:7 Changed 2 years ago by Brian Vandenberg <phantall+boost@…>


comment:8 Changed 2 years ago by andysem

  • Status changed from new to closed
  • Resolution set to fixed

(In [85873]) Disabled friend declarations for nested class templates for SunPro? compiler. Fixes #9153.

comment:9 Changed 2 years ago by Brian Vandenberg <phantall+boost@…>


I haven't found a download link for it, but back in 2008 they began releasing 'express' versions of the compiler suite. It may be possible to get an express version for the current sun studio compiler.


Add a comment

Modify Ticket

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'

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

Note: See TracTickets for help on using tickets.