Repository navigation
C++ reconstruction emits an unusable lambda closure type in a reference cast #586
jakub-labenski
started this conversation in
Issue Triage - Compilation
Replies: 1 comment
|
The underlying issue for this case seems to be that we don't keep the source spelling for some casts in the IL, e.g. using RVINT = int &&;
void f(int i)
{
auto &&v1 = static_cast<RVINT>(i);
auto && l = [] () { };
auto &&v2 = static_cast<decltype(l)>(l);
}Ideally, the C++-generating back end would reconstruct the static_casts as written, but instead we get: auto &&v1 = static_cast< int &&>(i);
auto &&l = []() { } ;
auto &&v2 = static_cast< class __T1 &&>(l); Currently, the IL only contains the expression type (which is the referenced type and can't be represented in terms of It's not clear yet how best to add the cast type to the IL. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
The C++-generating back end accepts the original source, but the reconstructed source fails to compile. When reconstructing a reference cast, the back end can emit a template alias whose argument is a synthetic name for the closure type of a lambda passed directly to a function.
Reproducing Source Code
Command-line Options
cpfe-cp --c++17 --gen_c_file_name=reconstructed.cpp repro.cpp && cpfe --c++17 --no_code_gen reconstructed.cpp
Type of Issue
[Back End] There is a problem with the generated C++ code.
Additional Details
Actual and expected behavior
The generated cast is equivalent to static_cast<R<value_t>&&>(r). The synthetic class __T1 introduces an incomplete class in the generated source, so value_t<__T1> fails when its decltype operand tries to call an object of that type.
The reconstructed source should compile. In this example, the cast can use the resolved destination type R&&.
Regression details
I bisected the failure to 76fe331 (EDGcpfe/26294). Its parent, 13ed541, emits R&& and recompiles successfully. Applying only the commit’s src/il_to_str.c change to the parent reproduces the failure. I also reproduced it with the 6.8 mainline sources at 8544c72 under the same C++-generating configuration.
Reproducing (Standard) Configuration(s)
linux-gcc-debug
Reproducing (Non-standard) Configuration
No response
I acknowledge that:
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.All reactions