Closed bluetarpmedia closed 3 months ago
I found another example except this time it's not with CTAD:
main: () -> int = {
m: std::mutex = ();
_: std::unique_lock<std::mutex> = (m);
return 0;
}
(Skipping the lowering.)
GCC error:
unique_lock.h:66:16: note: conversion of argument 1 would be ill-formed:
<source>:5:51: error: cannot bind non-const lvalue reference of type 'std::unique_lock<std::mutex>::mutex_type&' {aka 'std::mutex&'} to an rvalue of type 'std::remove_reference<std::mutex&>::type' {aka 'std::mutex'}
5 | std::unique_lock<std::mutex> auto_1 (std::move(m));
| ~~~~~~~~~^~~
Thanks! See #1030, this should now be fixed in the above commit.
Both code examples above will now work.
Describe the bug Cppfront generates a
std::move
for the last-use of an object, but this can cause problems if that last-use is an argument passed to a constructor which is relying on CTAD.To Reproduce Run Cppfront on this code:
It lowers to:
This results in a compilation error, e.g. with Clang:
(Similar errors with MSVC and GCC.)
See Godbolt