cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

[BUG] Semantic analysis to find the last use cannot find the enclosing scope

Open threeifbyair opened this issue 9 months ago • 0 comments

Describe the bug Cppfront crashes with an assertion on this code:

h: (s: std::string, inout m: std::map<const int,std::string> ) -> std::string
= {
    do { } while false;
    for m do (_) { 
        return :() -> std::string = (s + m[0])$;
    }
}

To Reproduce Go to the Godbolt link above, or try to compile this code.

Additional context The problem is in semantic analysis in sema::find_definite_last_uses while popping out of any containing scope of the last use. We skip over the actual start of the scope and find the end of a previous loop, which causes an assertion. Sadly I don't yet know the code quite intimately enough to know for sure what the fix is.

threeifbyair avatar Apr 12 '25 16:04 threeifbyair