C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Bringing break/continue with label to C++

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Thu, 19 Dec 2024 21:08:55 +0300
On 12/19/24 19:42, Oliver Hunt wrote:
>
>
>> On Dec 19, 2024, at 2:32 AM, Andrey Semashev via Std-Proposals <std-
>> proposals_at_[hidden]> wrote:
>>
>> On 12/19/24 07:53, Oliver Hunt wrote:
>>>
>>>
>>> Yes. I literally just gave an example, which is the entire motivation of
>>> this proposal: goto does not support continue or break semantics.
>>
>> It does. It's just your example (I'm assuming, it's the one quoted
>> above) is incorrect wrt. the existing goto semantics.
>
>
> Please, show me goto supporting the same semantics of labeled continue:
>
> label1: while (cond) {
> for (….) {
> if (x) continue label1;
> }
> }

  while (cond) {
     for (….) {
       if (x) goto label1;
     }
  label1:;
  }

> label1: for (int i = 0;i < n;i++) {
> for (….) {
> if (x) continue label1;
> }
> }

  for (int i = 0;i < n;i++) {
     for (….) {
       if (x) goto label1;
     }
  label1:;
  }

> label1: for (auto a: vec) {
> for (….) {
> if (x) continue label1;
> }
> }

  for (auto a: vec) {
     for (….) {
       if (x) goto label1;
     }
  label1:;
  }

I think, recent C or maybe even C++ versions have removed the need for
an empty statement (';') after a label, but I forget the details.

Received on 2024-12-19 18:08:58