You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you apply the statement decomposer to C++ auto expressions, e.g., auto start = high_resolution_clock::now();, it will decompose it into auto start; start = high_resolution_clock::now();, which is not valid C++ code. auto always expects an initialization in the same statement in order to infer the type, and this is broken by detaching the declaration from the initialization.
I think it is not reasonable to expect a developer to filter out these expressions before applying the decomposer, and that instead the decomposer should be the one doing the filtering. A more advanced solution would be to keep the decomposition but replace auto by its intended type, although that would require significant effort.
The text was updated successfully, but these errors were encountered:
Yes, the decomposer should have a check that skips declarations that are auto.
Also, as suggested, there could be a normalization step that transforms the auto type in the type of the initialization. Tentative code for that transformation could be:
I'm having problems replicating this issue. When applying the StatementDecomposer to code like auto a = foo(); or auto b = 1 + 3; it remains unchanged, and the pass that might do the change you were referring to, DecomposeVarDeclarations, already handles auto.
It might be an edge case that is slipping through, please provide example code in order to replicate the issue.
If you apply the statement decomposer to C++
auto
expressions, e.g.,auto start = high_resolution_clock::now();
, it will decompose it intoauto start; start = high_resolution_clock::now();
, which is not valid C++ code.auto
always expects an initialization in the same statement in order to infer the type, and this is broken by detaching the declaration from the initialization.I think it is not reasonable to expect a developer to filter out these expressions before applying the decomposer, and that instead the decomposer should be the one doing the filtering. A more advanced solution would be to keep the decomposition but replace
auto
by its intended type, although that would require significant effort.The text was updated successfully, but these errors were encountered: