Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

Compiler bug in tuple conversion

JJ9
Beginner
167 Views

Getting compile error for the following code segment on ICL 16.0.3.207. The code compiles fine on Visual Studio, GCC and clang.

#include <tuple>

void foobar()
  {
    struct A;
    A* a = nullptr;
    std::tuple<const A&> t {std::tie(*a)};
  }

The problem seems to be triggered by incomplete types.

0 Kudos
7 Replies
olzhas_r_
New Contributor I
167 Views

Isn't dereferencing a nullptr undefined? (Compiler can do whatever)

JJ9
Beginner
167 Views

olzhas r. wrote:

Isn't dereferencing a nullptr undefined? (Compiler can do whatever)

That would be an error if I'm dereferencing pointer to value (eg. A* to A). Dereferencing pointer to reference is legal (eg. A* to A&). The compiler has no problems with this in the call to tie(). The problem I'm trying to highlight is that the compiler refuses to construct tuple<const A&> from tuple<A&> when A is an incomplete type.

Melanie_B_Intel
Employee
167 Views

Yes I can reproduce this problem in our Windows compiler.  It's ok in our Linux compiler.

I opened DPD200413633 in our internal bug tracking database. Thank you for reporting it.

olzhas_r_
New Contributor I
167 Views

JJ wrote:

That would be an error if I'm dereferencing pointer to value (eg. A* to A). Dereferencing pointer to reference is legal (eg. A* to A&).

It is still not legal. It would mean a null reference were defined in C++.: http://stackoverflow.com/questions/2727834/c-standard-dereferencing-null-pointer-to-get-a-reference

Judith_W_Intel
Employee
167 Views

 

The workaround would be to declare the complete type of S before the rest of the code.

the problem seems to revolve around an incompatibility in the Intel compiler's __is_convertible_to type trait, i.e.

this compiles with MSVC++ 2015 but not Intel. Thanks for reporting it to us.

 

struct A;

 

template<class _This>

struct C

{

   static_assert(__is_convertible_to(const _This&, _This), "FAIL");

};

 

 

C<A&> _Ttype

JJ9
Beginner
167 Views

Hi, still seeing the bug in ICL 18.0.1.156

Regression, or was this never fixed?

Judith_W_Intel
Employee
167 Views

 

This bug is still open

Reply