Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
42 Views

Compiler bug in tuple conversion

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
Highlighted
New Contributor I
42 Views

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

0 Kudos
Highlighted
Beginner
42 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
Highlighted
42 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
Highlighted
New Contributor I
42 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
Highlighted
Employee
42 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
Highlighted
Beginner
42 Views

Hi, still seeing the bug in ICL 18.0.1.156

Regression, or was this never fixed?

0 Kudos
Highlighted
Employee
42 Views

 

This bug is still open

0 Kudos