Skip to content

clang-repl can not correctly execute top-level for-loop statements #89506

@wlonestar

Description

@wlonestar

Consider the following piece of code:

for (int i = 0; i < 3; i++) {
  for (int j = 0; j < 3; j++) {
    std::cout << i << ":" << j << "\n";
  }
}

When running this code in clang-repl I found it will set i, j as global variables, so the output will be:

0:0
0:1
0:2

I have to put the double loops into a function and execute the function, but this contradicts the original intention of the usage of interpreter.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions