Modify

Ticket #8943 (closed Bugs: fixed)

Opened 9 months ago

Last modified 7 months ago

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

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

Change History

Changed 9 months ago by avrarov@…

Proposed solution. Tested with all listed above compilers.

comment:1 Changed 9 months ago by viboes

  • Owner set to viboes
  • Status changed from new to assigned
  • Component changed from None to thread

comment:2 follow-up: ↓ 4 Changed 9 months ago by viboes

Could you try this patch

Replace

#ifndef BOOST_MSVC 

by

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

comment:3 Changed 8 months ago by viboes

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

comment:4 in reply to: ↑ 2 Changed 8 months ago by abrarov@…

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 Changed 8 months ago by viboes

  • Milestone changed from To Be Determined to Boost 1.55.0

Committed revision [85539].

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

comment:6 Changed 7 months ago by viboes

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

(In [85622]) Thread fix #8943.

View

Add a comment

Modify Ticket

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


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

 
Note: See TracTickets for help on using tickets.