Skip to content

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

Open
@threeifbyair

Description

@threeifbyair

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @threeifbyair

        Issue actions

          [BUG] Semantic analysis to find the last use cannot find the enclosing scope · Issue #1386 · hsutter/cppfront