Opened 7 years ago

Last modified 7 years ago

#11550 assigned Bugs

Solaris - boost::call_once issues

Reported by: lcarreon@… Owned by: viboes
Milestone: To Be Determined Component: thread
Version: Boost 1.59.0 Severity: Problem
Keywords: Cc:

Description (last modified by viboes)

I compiled Boost 1.59.0 with Solaris Studio 12.4 in C++11 mode and I

get the following error messages:

"libs/thread/src/pthread/thread.cpp", line 144: Error: Overloading ambiguity between "boost::call_once<void(*)()>(boost::once_flag&, void(*)())" and "boost::call_once<void(&)()>(boost::once_flag&, void(&)())".
"libs/thread/src/pthread/thread.cpp", line 150: Error: Overloading ambiguity between "boost::call_once<void(*)()>(boost::once_flag&, void(*)())" and "boost::call_once<void(&)()>(boost::once_flag&, void(&)())".
"libs/context/src/posix/stack_traits.cpp", line 58: Error: Overloading ambiguity between "boost::call_once<void(&)(unsigned long*), unsigned long*>(boost::once_flag&, void(&)(unsigned long*), unsigned long*&&)" and "boost::call_once<void(*)(unsigned long*), unsigned long*>(boost::once_flag&, void(*)(unsigned long*), unsigned long*)".
"libs/context/src/posix/stack_traits.cpp", line 66: Error: Overloading ambiguity between "boost::call_once<void(&)(rlimit*), rlimit*>(boost::once_flag&, void(&)(rlimit*), rlimit*&&)" and "boost::call_once<void(*)(rlimit*), rlimit*>(boost::once_flag&, void(*)(rlimit*), rlimit*)".
"libs/coroutine/src/posix/stack_traits.cpp", line 56: Error: Overloading ambiguity between "boost::call_once<void(&)(unsigned long*), unsigned long*>(boost::once_flag&, void(&)(unsigned long*), unsigned long*&&)" and "boost::call_once<void(*)(unsigned long*), unsigned long*>(boost::once_flag&, void(*)(unsigned long*), unsigned long*)".
"libs/coroutine/src/posix/stack_traits.cpp", line 64: Error: Overloading ambiguity between "boost::call_once<void(&)(rlimit*), rlimit*>(boost::once_flag&, void(&)(rlimit*), rlimit*&&)" and "boost::call_once<void(*)(rlimit*), rlimit*>(boost::once_flag&, void(*)(rlimit*), rlimit*)".
"./boost/thread/once.hpp", line 38: Error: Overloading ambiguity between "boost::call_once<void(*)()>(boost::once_flag&, void(*)())" and "boost::call_once<void(*)()&>(boost::once_flag&, void(*)()&)".
"./boost/spirit/home/classic/core/non_terminal/impl/object_with_id.ipp", line 145: Error: Overloading ambiguity between "boost::call_once<void(*)()>(boost::once_flag&, void(*)())" and "boost::call_once<void(&)()>(boost::once_flag&, void(&)())".
"./boost/spirit/home/classic/phoenix/closures.hpp", line 427: Error: Overloading ambiguity between "boost::call_once<void(*)()>(boost::once_flag&, void(*)())" and "boost::call_once<void(&)()>(boost::once_flag&, void(&)())".
"./boost/thread/once.hpp", line 38: Error: Overloading ambiguity between "boost::call_once<void(*)()>(boost::once_flag&, void(*)())" and "boost::call_once<void(*)()&>(boost::once_flag&, void(*)()&)".
"./boost/spirit/home/classic/core/non_terminal/impl/object_with_id.ipp", line 145: Error: Overloading ambiguity between "boost::call_once<void(*)()>(boost::once_flag&, void(*)())" and "boost::call_once<void(&)()>(boost::once_flag&, void(&)())".
"./boost/thread/once.hpp", line 38: Error: Overloading ambiguity between "boost::call_once<void(*)()>(boost::once_flag&, void(*)())" and "boost::call_once<void(*)()&>(boost::once_flag&, void(*)()&)".
"./boost/spirit/home/classic/core/non_terminal/impl/object_with_id.ipp", line 145: Error: Overloading ambiguity between "boost::call_once<void(*)()>(boost::once_flag&, void(*)())" and "boost::call_once<void(&)()>(boost::once_flag&, void(&)())".
"./boost/spirit/home/classic/phoenix/closures.hpp", line 427: Error: Overloading ambiguity between "boost::call_once<void(*)()>(boost::once_flag&, void(*)())" and "boost::call_once<void(&)()>(boost::once_flag&, void(&)())".
"./boost/thread/once.hpp", line 38: Error: Overloading ambiguity between "boost::call_once<void(*)()>(boost::once_flag&, void(*)())" and "boost::call_once<void(*)()&>(boost::once_flag&, void(*)()&)".
"./boost/spirit/home/classic/core/non_terminal/impl/object_with_id.ipp", line 145: Error: Overloading ambiguity between "boost::call_once<void(*)()>(boost::once_flag&, void(*)())" and "boost::call_once<void(&)()>(boost::once_flag&, void(&)())".
"./boost/thread/once.hpp", line 38: Error: Overloading ambiguity between "boost::call_once<void(*)()>(boost::once_flag&, void(*)())" and "boost::call_once<void(*)()&>(boost::once_flag&, void(*)()&)".
"./boost/spirit/home/classic/core/non_terminal/impl/object_with_id.ipp", line 145: Error: Overloading ambiguity between "boost::call_once<void(*)()>(boost::once_flag&, void(*)())" and "boost::call_once<void(&)()>(boost::once_flag&, void(&)())".

I'm not 100% sure whether these are compiler issues or Boost compiler configuration issues thus I decided to raise this ticket.

Change History (10)

comment:1 by John Maddock, 7 years ago

Component: Building Boostthread
Owner: set to Anthony Williams

comment:2 by John Maddock, 7 years ago

I believe this has been fixed now in https://github.com/boostorg/thread/pull/60

comment:3 by lcarreon@…, 7 years ago

FYI, I tried implementing the code change mentioned above. It is now complaining about this:

"./boost/thread/pthread/once_atomic.hpp", line 168: Error: Overloading ambiguity between "boost::detail::invoke<void, void(*)(rlimit*), rlimit*>(void(*)(rlimit*)&, rlimit*)" and "boost::detail::invoke<void, void(*)(rlimit*), rlimit*&>(void(*)(rlimit*)&, rlimit*&)".

Looking at the line being complained above, I realized it is in the part of the code where there is no support for variadic templates and rvalue references. IMO, this is incorrect because according to the Solaris Studio 12.4 documentation, it does support these two C++11 features in C++11 mode. Only thread related features are missing. I'm not sure if there is a way to distinguish if the compiler is in C++11 mode or not.

Taking the above into consideration, I undid your changes described above and changed the boost/config/compiler/sunpro_cc.hpp file instead to move BOOST_NO_CXX11_VARIADIC_TEMPLATES to affect Solaris Studio 12.3 and below only. This new change has eliminated all the boost::call_once related errors but it did generate signal 11 errors in various libraries as mentioned in a comment in the compiler configuration file. It also generated template argument errors in Boost.Log and Boost.Variant (1 line each).

comment:4 by John Maddock, 7 years ago

We've cross posted:

However, the errors from invoke do not occur when building the thread lib, only when building the context lib which I believe has other errors as well, and won't be easy to fix.

BTW, I don't think that enabling a feature (variadic templates) which is known to cause problems is the right solution either.

comment:5 by viboes, 7 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned

comment:6 by viboes, 7 years ago

Description: modified (diff)

comment:7 by viboes, 7 years ago

Owner: changed from viboes to Andrey Semashev
Status: assignednew

There is a SUN specific code in

#if !(defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5130))
  template<typename Function>
  inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f)

Would this condition be satisfied with your compiler version? Could you show the report of the lines of the overloads that are ambiguous?

Assigning to Andrey in case he has a better understanding as he wrote once_atomic.

comment:8 by Andrey Semashev, 7 years ago

Umm, I can see there are lots of changes that I didn't do (the INVOKE part at least), so maybe I'm not the one with the better understanding currently. :)

To me this looks like a compiler bug that should be reported to Oracle. As a quick fix for invoke problem I can suggest #if-ing out the whole invoke.hpp contents for this compiler, so that BOOST_THREAD_PROVIDES_INVOKE is not defined and boost::bind is used instead. A more efficient fix might be to tweak the invoke overloads somehow but to do that it would require a lot more experimenting, which is difficult as I don't have the compiler.

comment:9 by viboes, 7 years ago

Owner: changed from Andrey Semashev to viboes
Status: newassigned

Oh, I see now that the call_once ambiguity has been avoided already.

comment:10 by viboes, 7 years ago

Summary: boost::call_once issuesSolaris - boost::call_once issues
Note: See TracTickets for help on using tickets.