Opened 9 years ago

Closed 9 years ago

#8943 closed Bugs (fixed)

Failed to compile code using boost::call_once with Intel C++ Composer XE 2013 on Windows

Reported by: abrarov@… Owned by: viboes
Milestone: Boost 1.55.0 Component: thread
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:

Description

Environment:

  1. Windows 8 Pro x64 Russian.
  2. MS Visual Studio Ultimate 2012 Update 2.
  3. Intel C++ Composer XE 2013 (Intel C++ Compiler XE 13.0.0.089 for Windows).

Tried to compile this code:

#if defined(WIN32)
#include <tchar.h>
#endif

#include <cstdlib>
#include <iostream>
#include <boost/thread/once.hpp>

namespace {

class foo
{
public:
  void operator()() const
  {
    std::cout << "foo" << std::endl;
  }
}; // class foo

}

#if defined(WIN32)
int _tmain(int /*argc*/, _TCHAR* /*argv*/[])
#else
int main(int /*argc*/, char* /*argv*/[])
#endif
{
  try
  {
    boost::once_flag once_flag = BOOST_ONCE_INIT;
    boost::call_once(once_flag, foo());
    return EXIT_SUCCESS;
  }
  catch (...)
  {
    std::cerr << "Unknown exception" << std::endl;
  }
  return EXIT_FAILURE;
}

Got compiler output with this error:

>main.cpp(31): error : more than one instance of overloaded function "boost::call_once" matches the argument list:
>              function template "void boost::call_once(boost::once_flag &, Function)"
>              function template "void boost::call_once(boost::once_flag &, Function &&)"
>              argument types are: (boost::once_flag, <unnamed>::foo)
>        boost::call_once(once_flag, foo());
>        ^

There is no such error (tested) with:

  • MS Visual C++ 2012 Update 3 (Visual Studio 2012 Update 3 on Windows 8 Pro x64 Rus),
  • Visual C++ 2010 (Visual Studio 2010 on Windows 7 Pro SP1 Rus),
  • Visual C++ 2008 (Visual Studio 2008 on Windows XP Pro SP3 Rus).

Attachments (1)

intel_thread_once.patch (6.9 KB ) - added by avrarov@… 9 years ago.
Proposed solution. Tested with all listed above compilers.

Download all attachments as: .zip

Change History (7)

by avrarov@…, 9 years ago

Attachment: intel_thread_once.patch added

Proposed solution. Tested with all listed above compilers.

comment:1 by viboes, 9 years ago

Component: Nonethread
Owner: set to viboes
Status: newassigned

comment:2 by viboes, 9 years ago

Could you try this patch

Replace

#ifndef BOOST_MSVC 

by

#if ! defined(BOOST_MSVC) && ! defined(BOOST_INTEL)

comment:3 by viboes, 9 years ago

Summary: Failed to compile code using boost::call_once with Intel C++ Composer XE 2013Failed to compile code using boost::call_once with Intel C++ Composer XE 2013 on Windows

in reply to:  2 comment:4 by abrarov@…, 9 years ago

Replying to viboes:

Could you try this patch

Replace

#ifndef BOOST_MSVC 

by

#if ! defined(BOOST_MSVC) && ! defined(BOOST_INTEL)

This was the first solution I've done. But I think that this #if/#endif block isn't necessary at all (may produce errors for other compilers).

comment:5 by viboes, 9 years ago

Milestone: To Be DeterminedBoost 1.55.0

Committed revision [85539].

I would take some more time to refactor the call_once code windows implementation.

comment:6 by viboes, 9 years ago

Resolution: fixed
Status: assignedclosed

(In [85622]) Thread fix #8943.

Note: See TracTickets for help on using tickets.