- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 (https://gcc.godbolt.org/), 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; }
- Tags:
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank for report this issue. I've opened case CMPLRIL0-32276 to track it internally.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page