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

Compiler bug in tuple conversion

JJ9
Beginner
753 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
753 Views

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

0 Kudos
JJ9
Beginner
753 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.

0 Kudos
Melanie_B_Intel
Employee
753 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.

0 Kudos
olzhas_r_
New Contributor I
753 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

0 Kudos
Judith_W_Intel
Employee
753 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

0 Kudos
JJ9
Beginner
753 Views

Hi, still seeing the bug in ICL 18.0.1.156

Regression, or was this never fixed?

0 Kudos
Judith_W_Intel
Employee
753 Views

 

This bug is still open

0 Kudos
Reply