# translate-c: wrap switch statements in a while \(true\) loop · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/e761e0ac18aa1eab22b9547d702067910ed82c4a)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: e761e0ac18aa1eab22b9547d702067910ed82c4a

Requested commit: e761e0ac18aa1eab22b9547d702067910ed82c4a

Commit: e761e0ac18aa1eab22b9547d702067910ed82c4a

Tree: 2051a37e060386eab8b52152b6f478bc6e54945a

Author: Evan Haas

Committer: Andrew Kelley

## Message

```
translate-c: wrap switch statements in a while (true) loop

This allows `break` statements to be directly translated from the original C.
Add a break statement as the last statement of the while loop to ensure we
don't have an infinite loop if no breaks / returns are hit in the switch.

Fixes #8387

```

## Parents

- [36a33c99e3bc0825ada2ce1b374c32b4d6dee6b0](https://git.cafe/gitcafe/zig/commit/36a33c99e3bc0825ada2ce1b374c32b4d6dee6b0?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/e761e0ac18aa1eab22b9547d702067910ed82c4a?format=markdown)
