Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Ferraro__Luca
Beginner
171 Views

BOOST_SCOPE_EXIT error overloaded function is not a type name

Dear Intel C++ compiler users and support, I recently tried to compile a code which uses the Boost.ScopeExit facility.

Unfortunately, a simple code using BOOST v1.66 (reported in the details section) does not compile with Intel 2017, nor with Intel 2018. Using the compiler flag -std=g++98 all works correctly, but not with -std=gnu++11 (details follow). The problem seems to be related with the C++ standard, and not from the GNU extensions.

Is there any rationale for this behavior? What do you think is going on? Is it correct to assume icpc uses C++03 as default standard?

Thank you in advance for any help or clarification.

DETAILS:

Here follows the simple code used to test the BOOST_SCOPE_EXIT facility from BOOST 1.66. I assume boost header are installed in the BOOST_INC directory.

#include <boost/scope_exit.hpp>
#include <iostream>

int *foo()
{
  int *i = new int{10};
  BOOST_SCOPE_EXIT(&i)
  {
    delete i;
    i = 0;
  } BOOST_SCOPE_EXIT_END
  std::cout << *i << '\n';
  return i;
}

int main()
{
  int *j = foo();
  std::cout << j << '\n';
}

Compiling this code with Intel 2017 results in the following compiling errors:

$> icpc --version
icpc (ICC) 17.0.6 20171215
Copyright (C) 1985-2018 Intel Corporation.  All rights reserved.

$> icpc test_boost_scope_exit.cpp -I$BOOST_INC -o test_boost_scope_exit
test_boost_scope_exit.cpp(7): error: overloaded function "boost::scope_exit::detail::deref" is not a type name
    BOOST_SCOPE_EXIT(&i)
    ^

test_boost_scope_exit.cpp(7): error: expected a ")"
    BOOST_SCOPE_EXIT(&i)
    ^

test_boost_scope_exit.cpp(7): error: expected a type specifier
    BOOST_SCOPE_EXIT(&i)
    ^

test_boost_scope_exit.cpp(7): error #303: explicit type is missing ("int" assumed)
    BOOST_SCOPE_EXIT(&i)
    ^

test_boost_scope_exit.cpp(7): error: expected a ";"
    BOOST_SCOPE_EXIT(&i)
    ^

test_boost_scope_exit.cpp(7): error: identifier "boost_se_capture_t_0_7" is undefined
    BOOST_SCOPE_EXIT(&i)
    ^

compilation aborted for test_boost_scope_exit.cpp (code 2)

Similar behavior is obtained for Intel 2018 (18.0.1) . I'm using GNU 6.3. The code compile only if using the -std=g++98 compiler flag, but not with -std=g++11.

Inspecting the preprocessed source using default behaviour (-std=c++11) and altering the standard with -std=gnu++98, I found that the BOOST_TYPEOF_KEYWORD is not resolved using the c++11 standard:

$> icpc -E -std=c++11 test_boost_scope_exit.cpp -I $BOOST_INC |grep -A4 "foo()"
int *foo()
{
  int *i = new int{10};
  typedef void (*boost_se_tag_0_7)(int &i);   typedef BOOST_TYPEOF_KEYWORD(::boost::scope_exit::detail::deref(&i, static_cast<boost_se_tag_0_7>(0))) boost_se_capture_t_0_7 ;    struct boost_se_params_t_7 { typedef boost_se_capture_t_0_7 boost_se_param_t_0_7 ;    ::boost::scope_exit::detail::member< boost_se_param_t_0_7, boost_se_tag_0_7 > boost_se_param_0_7;    boost_se_params_t_7(  boost_se_param_t_0_7 & a0    ) :  boost_se_param_0_7 ( a0 )    {} } boost_se_params_7 (  ::boost::scope_exit::detail::deref(&i, static_cast<boost_se_tag_0_7>(0))     ) ; ::boost::scope_exit::detail::declared< ::boost::scope_exit::detail::resolve< sizeof(boost_scope_exit_aux_args) > ::cmp1<0> ::cmp2 > boost_scope_exit_aux_args; boost_scope_exit_aux_args . value = &boost_se_params_7; struct boost_se_guard_t_7 { boost_se_params_t_7* boost_se_params_; boost_se_guard_t_7 (void* boost_se_params) : boost_se_params_( (boost_se_params_t_7*)boost_se_params) {} ~boost_se_guard_t_7() { boost_se_body(  boost_se_params_->boost_se_param_0_7 . value     ); } static void boost_se_body(   boost_se_params_t_7:: boost_se_param_t_0_7 &i     )
  {
--
  int *j = foo();
  std::cout << j << '\n';
}

$> icpc -E -std=gnu++98 test_boost_scope_exit.cpp -I $BOOST_INC |grep -A4 "foo()"
int *foo()
{
  int *i = new int{10};
  typedef void (*boost_se_tag_0_7)(int &i);   typedef __typeof__(::boost::scope_exit::detail::deref(&i, static_cast<boost_se_tag_0_7>(0))) boost_se_capture_t_0_7 ;    struct boost_se_params_t_7 { typedef boost_se_capture_t_0_7 boost_se_param_t_0_7 ;    ::boost::scope_exit::detail::member< boost_se_param_t_0_7, boost_se_tag_0_7 > boost_se_param_0_7;    boost_se_params_t_7(  boost_se_param_t_0_7 & a0    ) :  boost_se_param_0_7 ( a0 )    {} } boost_se_params_7 (  ::boost::scope_exit::detail::deref(&i, static_cast<boost_se_tag_0_7>(0))     ) ; ::boost::scope_exit::detail::declared< ::boost::scope_exit::detail::resolve< sizeof(boost_scope_exit_aux_args) > ::cmp1<0> ::cmp2 > boost_scope_exit_aux_args; boost_scope_exit_aux_args . value = &boost_se_params_7; struct boost_se_guard_t_7 { boost_se_params_t_7* boost_se_params_; boost_se_guard_t_7 (void* boost_se_params) : boost_se_params_( (boost_se_params_t_7*)boost_se_params) {} ~boost_se_guard_t_7() { boost_se_body(  boost_se_params_->boost_se_param_0_7 . value     ); } static void boost_se_body(   boost_se_params_t_7:: boost_se_param_t_0_7 &i     )
  {
--
  int *j = foo();
  std::cout << j << '\n';
}
0 Kudos
2 Replies
171 Views

Same problem here with Boost 1.65.1 and c++11.

171 Views

I am affected by the same problem and have reported it with boost developers here: https://svn.boost.org/trac10/ticket/13499

Reply