I took your example, converted it to C++20, using goto, and substituted bbi (https://github.com/HowardHinnant/bbi) 8 bit signed integers that terminate on overflow for your two ints:

#include <iostream>
#include "bbi.h"

int
main()
{
    using namespace bbi::term;
    i8 x{0};
    for (i8 i{0}; i < 5; i++)
    {
repeat:
        x++;
        std::cout << "i = " << i << ", x = " << x << '\n';
        if (x != 2)
            goto repeat;
    }
}

The reason I used 8 bit integers was to turn what seemed like an infinite loop into a short loop.  And the reason I chose to terminate on signed int overflow was to expose the undefined behavior in your example, and define it as std::terminate.  Furthermore I augmented your “Hello\n” with the current values of i and x.

The output is:

i = 0, x = 1

i = 0, x = 2

i = 1, x = 3

i = 1, x = 4

i = 1, x = 5

i = 1, x = 6

i = 1, x = 7

i = 1, x = 8

i = 1, x = 9

i = 1, x = 10

i = 1, x = 11

i = 1, x = 12

i = 1, x = 13

i = 1, x = 14

i = 1, x = 15

i = 1, x = 16

i = 1, x = 17

i = 1, x = 18

i = 1, x = 19

i = 1, x = 20

i = 1, x = 21

i = 1, x = 22

i = 1, x = 23

i = 1, x = 24

i = 1, x = 25

i = 1, x = 26

i = 1, x = 27

i = 1, x = 28

i = 1, x = 29

i = 1, x = 30

i = 1, x = 31

i = 1, x = 32

i = 1, x = 33

i = 1, x = 34

i = 1, x = 35

i = 1, x = 36

i = 1, x = 37

i = 1, x = 38

i = 1, x = 39

i = 1, x = 40

i = 1, x = 41

i = 1, x = 42

i = 1, x = 43

i = 1, x = 44

i = 1, x = 45

i = 1, x = 46

i = 1, x = 47

i = 1, x = 48

i = 1, x = 49

i = 1, x = 50

i = 1, x = 51

i = 1, x = 52

i = 1, x = 53

i = 1, x = 54

i = 1, x = 55

i = 1, x = 56

i = 1, x = 57

i = 1, x = 58

i = 1, x = 59

i = 1, x = 60

i = 1, x = 61

i = 1, x = 62

i = 1, x = 63

i = 1, x = 64

i = 1, x = 65

i = 1, x = 66

i = 1, x = 67

i = 1, x = 68

i = 1, x = 69

i = 1, x = 70

i = 1, x = 71

i = 1, x = 72

i = 1, x = 73

i = 1, x = 74

i = 1, x = 75

i = 1, x = 76

i = 1, x = 77

i = 1, x = 78

i = 1, x = 79

i = 1, x = 80

i = 1, x = 81

i = 1, x = 82

i = 1, x = 83

i = 1, x = 84

i = 1, x = 85

i = 1, x = 86

i = 1, x = 87

i = 1, x = 88

i = 1, x = 89

i = 1, x = 90

i = 1, x = 91

i = 1, x = 92

i = 1, x = 93

i = 1, x = 94

i = 1, x = 95

i = 1, x = 96

i = 1, x = 97

i = 1, x = 98

i = 1, x = 99

i = 1, x = 100

i = 1, x = 101

i = 1, x = 102

i = 1, x = 103

i = 1, x = 104

i = 1, x = 105

i = 1, x = 106

i = 1, x = 107

i = 1, x = 108

i = 1, x = 109

i = 1, x = 110

i = 1, x = 111

i = 1, x = 112

i = 1, x = 113

i = 1, x = 114

i = 1, x = 115

i = 1, x = 116

i = 1, x = 117

i = 1, x = 118

i = 1, x = 119

i = 1, x = 120

i = 1, x = 121

i = 1, x = 122

i = 1, x = 123

i = 1, x = 124

i = 1, x = 125

i = 1, x = 126

i = 1, x = 127

Z<Signed, 8, Terminate>{127} + Z<Signed, 8, Terminate>{1} overflowed

libc++abi: terminating

Abort trap: 6


I’m posting this experiment for two reasons:

  1.  When showing a motivating example for your proposal, give it good behavior.  No UB.  No infinite loops.
  2.  Feel free to use the header-only-library bbi to help you do that.  It does require C++20.

Howard

On Nov 16, 2026, at 11:41 AM, scbd Gm via Std-Proposals <std-proposals@lists.isocpp.org> wrote:

Hello everyone,

I'm interested in proposing a new C++ control-flow statement called repeat.

The motivation is to provide a dedicated way to restart the current loop iteration immediately, without executing the remaining statements or the loop's increment expression.

For example:

int x = 0;

for (int i = 0; i < 5; i++)
{
    x++;

    cout << "Hello\n";

    if (x != 2)
        repeat;
}

My proposed semantics are:

  1. Restart the innermost enclosing loop body.

  2. Skip the remaining statements of the current iteration.

  3. Do not execute the loop's increment expression.

  4. Destroy and reinitialize local objects belonging to the loop body's scope.

  5. Preserve variables declared outside the loop body.

  6. Support for, while, and do-while loops.

I believe this could provide a cleaner and more expressive alternative to certain uses of goto and nested loops.

I would appreciate feedback on:

  • Whether this feature offers sufficient practical value.

  • Whether similar functionality has been proposed before.

  • Potential problems with object lifetimes, destructors, and exception handling.

  • Whether this idea could be worth developing into a formal C++ proposal.

This is an early-stage idea, and I would appreciate constructive criticism.

Thank you!


--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals