Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #167320

Re: labels at the end of a function

From Ike Naar <ike@sdf.org>
Newsgroups comp.lang.c, comp.lang.fortran, comp.lang.c++
Subject Re: labels at the end of a function
Followup-To comp.lang.c, comp.lang.c++
Date 2022-08-30 05:50 +0000
Organization A noiseless patient Spider
Message-ID <slrntgr99e.mjd.ike@sdf.org> (permalink)
References <tejphm$19h6e$1@dont-email.me>

Cross-posted to 3 groups.

Followups directed to: comp.lang.c, comp.lang.c++

Show all headers | View raw


On 2022-08-30, Lynn McGuire <lynnmcguire5@gmail.com> wrote:
> I just found out that a label at the end of a c/c++ function must have 
> an executable statement after it.
>
> int aMethod ()
> {
> 	int aFakeVar = 0;
>
> 	goto aLabel;
>
> 	aLabel:
>
> 	aFakeVar++;
> }
>
> Is there any way to get around the requirement of the executable 
> statement after the label ?

Put an empty statement after the label:

  int aMethod()
  {
    /* ... */
    goto aLabel;
    /* ... */
    aLabel:
    ;
  }

or use ``return'' instead of ``goto'':

  int aMethod()
  {
    /* ... */
    return;
    /* ... */
  }

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

labels at the end of a function Lynn McGuire <lynnmcguire5@gmail.com> - 2022-08-29 20:35 -0500
  Re: labels at the end of a function Thiago Adams <thiago.adams@gmail.com> - 2022-08-29 18:47 -0700
    Re: labels at the end of a function Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-29 21:50 -0700
      Re: labels at the end of a function Kaz Kylheku <480-992-1380@kylheku.com> - 2022-08-30 05:52 +0000
  Re: labels at the end of a function Sam <sam@email-scan.com> - 2022-08-29 22:42 -0400
    Re: labels at the end of a function Anton Shepelev <anton.txt@g{oogle}mail.com> - 2022-08-30 12:46 +0300
      Re: labels at the end of a function Juha Nieminen <nospam@thanks.invalid> - 2022-08-30 11:20 +0000
      Re: labels at the end of a function Opus <ifonly@youknew.org> - 2022-08-30 20:15 +0200
  Re: labels at the end of a function Ike Naar <ike@sdf.org> - 2022-08-30 05:50 +0000
    Re: labels at the end of a function Elephant <diespammer@yahoo.it> - 2022-08-30 10:14 +0200
  Re: labels at the end of a function Bo Persson <bo@bo-persson.se> - 2022-08-30 09:14 +0200
  Re: labels at the end of a function scott@slp53.sl.home (Scott Lurndal) - 2022-08-30 13:21 +0000
    Re: labels at the end of a function gazelle@shell.xmission.com (Kenny McCormack) - 2022-08-30 14:44 +0000
      Re: labels at the end of a function Lynn McGuire <lynnmcguire5@gmail.com> - 2022-08-30 16:08 -0500
        Re: labels at the end of a function Anton Shepelev <anton.txt@gmail.com> - 2022-08-31 01:04 +0300
  Re: labels at the end of a function Lynn McGuire <lynnmcguire5@gmail.com> - 2022-08-30 20:29 -0500

csiph-web