Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.
7783 Discussions

Intel 19 type-deduction allows non-const lvalue reference to prvalue


Intel 19 (Update 5) for Windows seems to have introduced a regression in which it is possible to bind a non-const l-value reference to a temporary (prvalue) during type-deduction. In previous versions of Visual Studio, these kind of "loose" reference bindings were permitted via a Microsoft Language extension but is non-conformant and has since been disallowed. This code is correctly flagged as aberrant in VS2019 (16.3.9) when compiled with /permissive- (the default). Compiled on ICC 19.0.1 here (, this code generates errors as well.

#include <cstdio>

struct T
   T(char ch) : m_ch( ch ) { printf("Constructing '%c' (0x%08p)\n", ch, this); }
  ~T() { printf("Destructing '%c' (0x%08p)\n", m_ch, this); }
   char m_ch;

T CreateT(char ch)
   return T{ch};

template <typename T_>
void Func1(T_&& t)
   printf("Calling Func1 on object '%c' (0x%08p)\n", t.m_ch, &t);

void Func2(T& t)
   printf("Calling Func2 on object '%c' (0x%08p)\n", t.m_ch, &t);

int main()
    const auto& a = CreateT('A'); // ok, const l-value reference to r-value
    auto&& b = CreateT('B'); // ok, deduces to r-value (T&&)
    Func1(CreateT('C')); // ok, deduces to T&&
    Func2(CreateT('D')); // error, cannot bind non-const l-value ref to r-value (Intel 19.0.5 allows this!)
    auto& d = CreateT('D'); // error, cannot bind non-const l-value ref to r-value (Intel 19.0.5 allows this!)

    return 0;


0 Kudos
1 Reply

Thank for report this issue. I've opened case CMPLRIL0-32276 to track it internally.