Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

noexcept and std::is_nothrow_move_constructible do not work as expected under windows

Raffael_C_
Beginner
412 Views

Hi,

After spending one day debugging some code I've found some really strange behaviour: Consider the following code

[cpp]

#include<iostream>
#include<type_traits>

struct A {
  A(A&& other) noexcept {}
  ~A() noexcept {}
};

struct B {
  B(B&& other) noexcept {

}

  ~B() {}
};

int main() {
  std::cout << std::is_nothrow_move_constructible<A>::value << std::endl;
  std::cout << std::is_nothrow_move_constructible<B>::value << std::endl;
}

[/cpp]

If I compile this with Intel Composer XE2014 SP1 Update 1 on Windows I get the following output on the the console:

[cpp]

1

0

[/cpp]

This means essentially that std::is_no_throw_move_constructible returns true only if the Move constructor AND the Destructor are marked as noexcept. I think this is not what is written in the standard. (gcc 4.8.2 and Clang 3.4 give the correct outpout, i.e. 1,1)

Cheers,

Raffael

P.S.: You can find the source code also attached to this message.

0 Kudos
2 Replies
Judith_W_Intel
Employee
412 Views

 

This is the for the same reason as your other note, we do not support implicit noexcept on the Windows platform.

http://software.intel.com/en-us/forums/topic/500462

 From our code:

   /* Microsoft compilers do not yet (as of Visual C++ 2013) implement
       noexcept.  We therefore keep the traditional relaxed semantics for
       destructors and operator delete. */
    implicit_noexcept_enabled = FALSE;

Judy
 

 

 

0 Kudos
Raffael_C_
Beginner
412 Views

Hi Judy,

Okay thanks for the answer. It's really too bad that it doesn't work completly but I have been able to work around it.

Cheers,

Raffael

0 Kudos
Reply