Skip to content

Conversation

@ktegan
Copy link

@ktegan ktegan commented Nov 29, 2025

This provides a simple solution to issue #1436 based on a the following comment "break" won't [work] until we do extra work to implement that using a flag and implementing "break" as "_for_break = true; continue;.

This would need code review because: there may be more elegant ways to do this, there are some details I'm not sure about (can print_cpp2() replace an emit() call?), and more testing for correctness would need to be done.

I think my biggest question is whether we should follow what the comment suggests or use an alternative approach where we define a default label for every loop and when there is a break that does not include a label add the label of the innermost loop to that break statement. If we used this labeled break solution the generated cpp1 code would use CPP2_CONTINUE_BREAK() to produce a goto statement instead of the solution in this PR which adds a variable and may require a comparison (check if _for_break is true) on every iteration through the loop.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant