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

(c++11) is_trivially_copy_constructible always false if class has destructor

Andrey_K_
Beginner
629 Views

Hi, when some class (T) has destructor is_trivially_copy_constructible<T>::value is always false.

For example:

//trivially copy constructable class with destructor
class CSomeClass {
public:
	int x;

	//explicitly specify default copy constructor
	CSomeClass(const CSomeClass&) = default;

	//non-default destructor
	~CSomeClass(){
	}
};

//all asserts below are failed
static_assert(is_trivially_copy_constructible<CSomeClass>::value, "not a trivially copy constructable"); 
static_assert(is_trivially_move_constructible<CSomeClass>::value, "not a trivially move constructable");
static_assert(is_trivially_constructible<CSomeClass, const CSomeClass&>::value,  "not a trivially copy constructable");
static_assert(is_trivially_constructible<CSomeClass, CSomeClass&&>::value, "not a trivially copy constructable");

If we remove destructor, all assertion will pass.

According C++11 specification (in my case I refer to draft n3376), is_trivially_copy_constructible<T> should be true when is_copy_constructible<T> is true and only trivial operations are involved.

So I think is_trivially_copy_constructible should be true in the above example.

I have installed the following compiler: Intel® C++ Composer XE 2015   Package ID : w_ccompxe_2015.0.030, for Microsoft* Visual Studio* 2013.

Btw, with ms vc120 compiler, all asserts are pass.

0 Kudos
1 Solution
Shenghong_G_Intel
629 Views

Hi Andrey,

I can reproduce the issue, I will track the issue in our problem tracking system. Hope to see it fixed (implemented) in future.

Note: This C++11 feature is even not supported by latest gcc 4.9.0 and ICC 15.0 Linux version.

Thanks,

Shenghong

View solution in original post

0 Kudos
1 Reply
Shenghong_G_Intel
630 Views

Hi Andrey,

I can reproduce the issue, I will track the issue in our problem tracking system. Hope to see it fixed (implemented) in future.

Note: This C++11 feature is even not supported by latest gcc 4.9.0 and ICC 15.0 Linux version.

Thanks,

Shenghong

0 Kudos
Reply