Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

All the evidence concerning the universe has not yet been collected, so there's still hope.


devel / comp.lang.fortran / labels at the end of a function

SubjectAuthor
* labels at the end of a functionLynn McGuire
+* Re: labels at the end of a functionPeter Klausler US
|+- Re: labels at the end of a functionLynn McGuire
|`- Re: labels at the end of a functiongah4
+* Re: labels at the end of a functionSam
|`* Re: labels at the end of a functionAnton Shepelev
| +- Re: labels at the end of a functionJuha Nieminen
| `- Re: labels at the end of a functionOpus
+- Re: labels at the end of a functionIke Naar
+- Re: labels at the end of a functionBo Persson
+* Re: labels at the end of a functionScott Lurndal
|`* Re: labels at the end of a functionKenny McCormack
| +* Re: labels at the end of a functiongah4
| |`* Re: labels at the end of a functionThomas Koenig
| | `- Re: labels at the end of a functiongah4
| `* Re: labels at the end of a functionLynn McGuire
|  `- Re: labels at the end of a functionAnton Shepelev
`- Re: labels at the end of a functionLynn McGuire

1
labels at the end of a function

<tejphm$19h6e$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2790&group=comp.lang.fortran#2790

  copy link   Newsgroups: comp.lang.c comp.lang.fortran comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: lynnmcguire5@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.c,comp.lang.fortran,comp.lang.c++
Subject: labels at the end of a function
Date: Mon, 29 Aug 2022 20:35:50 -0500
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <tejphm$19h6e$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 30 Aug 2022 01:35:50 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="f62188411efda3fa75a445186dfcdd7e";
logging-data="1361102"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Ia4yR3tb8edIkCUH6mwly"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.2.0
Cancel-Lock: sha1:2iyvwtXogPU3b7Evawrq8WJ1RTk=
Content-Language: en-US
 by: Lynn McGuire - Tue, 30 Aug 2022 01:35 UTC

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 ?

Thanks,
Lynn

Re: labels at the end of a function

<89605b6a-b625-448e-a3d6-1b1e7551ae52n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2791&group=comp.lang.fortran#2791

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ac8:5ad2:0:b0:344:90e7:410f with SMTP id d18-20020ac85ad2000000b0034490e7410fmr13203761qtd.625.1661824722196;
Mon, 29 Aug 2022 18:58:42 -0700 (PDT)
X-Received: by 2002:a25:343:0:b0:69a:d3d6:2809 with SMTP id
64-20020a250343000000b0069ad3d62809mr7125242ybd.467.1661824722028; Mon, 29
Aug 2022 18:58:42 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Mon, 29 Aug 2022 18:58:41 -0700 (PDT)
In-Reply-To: <tejphm$19h6e$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=12.154.207.45; posting-account=ZT-cAwoAAACx2tBPXm-WZoHIT8sjnGGy
NNTP-Posting-Host: 12.154.207.45
References: <tejphm$19h6e$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <89605b6a-b625-448e-a3d6-1b1e7551ae52n@googlegroups.com>
Subject: Re: labels at the end of a function
From: pklausler@nvidia.com (Peter Klausler US)
Injection-Date: Tue, 30 Aug 2022 01:58:42 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1548
 by: Peter Klausler US - Tue, 30 Aug 2022 01:58 UTC

On Monday, August 29, 2022 at 6:35:54 PM UTC-7, Lynn McGuire 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 ?
>
> Thanks,
> Lynn

Use an empty statement, i.e. "label:;".

Re: labels at the end of a function

<tejr23$1cg5v$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2793&group=comp.lang.fortran#2793

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: lynnmcguire5@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.fortran
Subject: Re: labels at the end of a function
Date: Mon, 29 Aug 2022 21:01:39 -0500
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <tejr23$1cg5v$1@dont-email.me>
References: <tejphm$19h6e$1@dont-email.me>
<89605b6a-b625-448e-a3d6-1b1e7551ae52n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 30 Aug 2022 02:01:39 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="f62188411efda3fa75a445186dfcdd7e";
logging-data="1458367"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4MhPbEIVOdifLKqFrjTBR"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.2.0
Cancel-Lock: sha1:C+N2hAewFivnpxPuQSTloA8WeP4=
Content-Language: en-US
In-Reply-To: <89605b6a-b625-448e-a3d6-1b1e7551ae52n@googlegroups.com>
 by: Lynn McGuire - Tue, 30 Aug 2022 02:01 UTC

On 8/29/2022 8:58 PM, Peter Klausler US wrote:
> On Monday, August 29, 2022 at 6:35:54 PM UTC-7, Lynn McGuire 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 ?
>>
>> Thanks,
>> Lynn
>
> Use an empty statement, i.e. "label:;".

Thanks for the advice. Sorry, I only meant to post to the C and C++ groups.

Lynn

Re: labels at the end of a function

<cone.1661827324.810372.52241.1004@monster.email-scan.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2794&group=comp.lang.fortran#2794

  copy link   Newsgroups: comp.lang.c comp.lang.fortran comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: sam@email-scan.com (Sam)
Newsgroups: comp.lang.c,comp.lang.fortran,comp.lang.c++
Subject: Re: labels at the end of a function
Date: Mon, 29 Aug 2022 22:42:04 -0400
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <cone.1661827324.810372.52241.1004@monster.email-scan.com>
References: <tejphm$19h6e$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; delsp=yes; charset="UTF-8"
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="ac3e32d01db50bf2c956043ed2040bff";
logging-data="1464691"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nbDuJYwOEfQzeXj1GrIUo"
Cancel-Lock: sha1:z293oJBHRaQrrZWqL+EK/SUV4p4=
X-Mailer: http://www.courier-mta.org/cone/
Content-Disposition: inline
 by: Sam - Tue, 30 Aug 2022 02:42 UTC

Lynn McGuire writes:

> 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 ?

There are two options:

1) get rid of the label and the goto. The more goto-s get written, the more
likely is it for Chulhu to appear and bring humanity to an end. Very messy.

2) a single semicolon should be executable enough. I'm too lazy to check. In
any case

if (0)
;

will definitely work.

Re: labels at the end of a function

<e732b8ff-89f7-4340-a096-4fad161abe09n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2795&group=comp.lang.fortran#2795

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ad4:5bad:0:b0:476:e202:32eb with SMTP id 13-20020ad45bad000000b00476e20232ebmr13688243qvq.3.1661837157054;
Mon, 29 Aug 2022 22:25:57 -0700 (PDT)
X-Received: by 2002:a25:d046:0:b0:695:cef7:4f2c with SMTP id
h67-20020a25d046000000b00695cef74f2cmr10616565ybg.245.1661837156828; Mon, 29
Aug 2022 22:25:56 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Mon, 29 Aug 2022 22:25:56 -0700 (PDT)
In-Reply-To: <89605b6a-b625-448e-a3d6-1b1e7551ae52n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:9436:1cc2:ea0:7fd3;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:9436:1cc2:ea0:7fd3
References: <tejphm$19h6e$1@dont-email.me> <89605b6a-b625-448e-a3d6-1b1e7551ae52n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e732b8ff-89f7-4340-a096-4fad161abe09n@googlegroups.com>
Subject: Re: labels at the end of a function
From: gah4@u.washington.edu (gah4)
Injection-Date: Tue, 30 Aug 2022 05:25:57 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1650
 by: gah4 - Tue, 30 Aug 2022 05:25 UTC

On Monday, August 29, 2022 at 6:58:43 PM UTC-7, Peter Klausler US wrote:

(snip)

> > Is there any way to get around the requirement of the executable
> > statement after the label ?

> Use an empty statement, i.e. "label:;".

It is called a null statement, but otherwise yes, it should work.

Since the function returns int, you will get a warning about no return statement.

You could put the return 0; or some other value, there.

Re: labels at the end of a function

<slrntgr99e.mjd.ike@sdf.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2796&group=comp.lang.fortran#2796

  copy link   Newsgroups: comp.lang.c comp.lang.fortran comp.lang.c++
Followup: comp.lang.c,comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ike@sdf.org (Ike Naar)
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: Tue, 30 Aug 2022 05:50:38 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <slrntgr99e.mjd.ike@sdf.org>
References: <tejphm$19h6e$1@dont-email.me>
Injection-Date: Tue, 30 Aug 2022 05:50:38 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="5914a599d153c3c822cd7742807b95a0";
logging-data="1489547"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183Y8ItstLpa1icJ4oownyP"
User-Agent: slrn/1.0.3 (Patched for libcanlock3) (NetBSD)
Cancel-Lock: sha1:VjJDcA/ky9yDIeRVA9Alsjzgboc=
 by: Ike Naar - Tue, 30 Aug 2022 05:50 UTC

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;
/* ... */
}

Re: labels at the end of a function

<jn5rn9Fa4c6U1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2798&group=comp.lang.fortran#2798

  copy link   Newsgroups: comp.lang.c comp.lang.fortran comp.lang.c++
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bo@bo-persson.se (Bo Persson)
Newsgroups: comp.lang.c,comp.lang.fortran,comp.lang.c++
Subject: Re: labels at the end of a function
Date: Tue, 30 Aug 2022 09:14:49 +0200
Lines: 23
Message-ID: <jn5rn9Fa4c6U1@mid.individual.net>
References: <tejphm$19h6e$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net 58SwpF68DfqhDHZAY1R6BQ6qZsZwKIBZvuMhxJFLXZheeIo+aF
Cancel-Lock: sha1:0t4hzlXGulN6ab6I8WTDHgK7i0o=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
Content-Language: sv
In-Reply-To: <tejphm$19h6e$1@dont-email.me>
 by: Bo Persson - Tue, 30 Aug 2022 07:14 UTC

On 2022-08-30 at 03:35, Lynn McGuire 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 ?
>

Not right now, but it will be allowed in C++23. :-)

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2324r2.pdf

Re: labels at the end of a function

<20220830124652.bab3908329ccf4b6cf52d33d@g{oogle}mail.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2799&group=comp.lang.fortran#2799

  copy link   Newsgroups: comp.lang.c comp.lang.fortran comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: anton.txt@g{oogle}mail.com (Anton Shepelev)
Newsgroups: comp.lang.c,comp.lang.fortran,comp.lang.c++
Subject: Re: labels at the end of a function
Date: Tue, 30 Aug 2022 12:46:52 +0300
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <20220830124652.bab3908329ccf4b6cf52d33d@g{oogle}mail.com>
References: <tejphm$19h6e$1@dont-email.me>
<cone.1661827324.810372.52241.1004@monster.email-scan.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="770a7bc106c3382f110e6063961ca7ae";
logging-data="1524699"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18aHzZ186TKmNOfJHzUYUGBk4+z/na9r9s="
Cancel-Lock: sha1:3y0MW33GNgU/HFdUK6MwecUPcho=
X-Newsreader: Sylpheed 3.5.0 (GTK+ 2.24.23; i686-pc-mingw32)
 by: Anton Shepelev - Tue, 30 Aug 2022 09:46 UTC

Sam:

> The more goto-s get written, the more likely is it for
> Chulhu to appear and bring humanity to an end.

I disagree. Structured use of GOTO's (the topic of a Knuch
article!), especially when they jump down and nest stack-
like can greately simplify certain code structures. They
help to avoid returns from mid-function, and let the
programmer execute common deinitialisation code. My standard
pattern of error-handling is based on GOTO's:

https://nedbatchelder.com/text/exceptions-vs-status.html#comment_15239

--
() ascii ribbon campaign - against html e-mail
/\ http://preview.tinyurl.com/qcy6mjc [archived]

Re: labels at the end of a function

<tekrpn$70v$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2800&group=comp.lang.fortran#2800

  copy link   Newsgroups: comp.lang.c comp.lang.fortran comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!NK0c7qMEn6mmBWqphs27pg.user.46.165.242.75.POSTED!not-for-mail
From: nospam@thanks.invalid (Juha Nieminen)
Newsgroups: comp.lang.c,comp.lang.fortran,comp.lang.c++
Subject: Re: labels at the end of a function
Date: Tue, 30 Aug 2022 11:20:25 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <tekrpn$70v$1@gioia.aioe.org>
References: <tejphm$19h6e$1@dont-email.me> <cone.1661827324.810372.52241.1004@monster.email-scan.com> <20220830124652.bab3908329ccf4b6cf52d33d@g{oogle}mail.com>
Injection-Info: gioia.aioe.org; logging-data="7199"; posting-host="NK0c7qMEn6mmBWqphs27pg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/5.10.103-grsec-kapsi (x86_64))
X-Notice: Filtered by postfilter v. 0.9.2
 by: Juha Nieminen - Tue, 30 Aug 2022 11:20 UTC

In comp.lang.c++ Anton Shepelev <anton.txt@g{oogle}mail.com> wrote:
>> The more goto-s get written, the more likely is it for
>> Chulhu to appear and bring humanity to an end.
>
> I disagree. Structured use of GOTO's (the topic of a Knuch
> article!), especially when they jump down and nest stack-
> like can greately simplify certain code structures. They
> help to avoid returns from mid-function, and let the
> programmer execute common deinitialisation code.

That may be true in C, but C++ throws a spanner in the works because
of one fun feature: Exceptions.

If running the deinitialization code is crucial (or else for example
resources will be leaked, such as file handles left open), it won't
be run no matter how many gotos you use if anything along the line
throws an exception and it's not caught.

This is one of the main reasons to use RAII instead of gotos: Object
destructors will always be run no matter how the function is exited,
be it an early return, be it an exception.

As a bonus, if you implement it properly, the code will actually become
cleaner.

Re: labels at the end of a function

<99oPK.21145$6Il8.5192@fx14.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2801&group=comp.lang.fortran#2801

  copy link   Newsgroups: comp.lang.c comp.lang.fortran comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx14.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: labels at the end of a function
Newsgroups: comp.lang.c,comp.lang.fortran,comp.lang.c++
References: <tejphm$19h6e$1@dont-email.me>
Lines: 19
Message-ID: <99oPK.21145$6Il8.5192@fx14.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 30 Aug 2022 13:21:09 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 30 Aug 2022 13:21:09 GMT
X-Received-Bytes: 998
 by: Scott Lurndal - Tue, 30 Aug 2022 13:21 UTC

Lynn McGuire <lynnmcguire5@gmail.com> writes:
>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 ?

Your function is missing a return statement.

Re: labels at the end of a function

<tel7o3$raj7$1@news.xmission.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2803&group=comp.lang.fortran#2803

  copy link   Newsgroups: comp.lang.c comp.lang.fortran comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.c,comp.lang.fortran,comp.lang.c++
Subject: Re: labels at the end of a function
Date: Tue, 30 Aug 2022 14:44:19 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <tel7o3$raj7$1@news.xmission.com>
References: <tejphm$19h6e$1@dont-email.me> <99oPK.21145$6Il8.5192@fx14.iad>
Injection-Date: Tue, 30 Aug 2022 14:44:19 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="895591"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Tue, 30 Aug 2022 14:44 UTC

In article <99oPK.21145$6Il8.5192@fx14.iad>,
Scott Lurndal <slp53@pacbell.net> wrote:
>Lynn McGuire <lynnmcguire5@gmail.com> writes:
>>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 ?
>
>Your function is missing a return statement.

Or they misspelled "void" as "int".

P.S. Why is this also posted to a Fortran group?

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/InsaneParty

Re: labels at the end of a function

<telk39$1osb$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2806&group=comp.lang.fortran#2806

  copy link   Newsgroups: comp.lang.c comp.lang.fortran comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!2EBed1tE9Z/9AUPY2rndVQ.user.46.165.242.75.POSTED!not-for-mail
From: ifonly@youknew.org (Opus)
Newsgroups: comp.lang.c,comp.lang.fortran,comp.lang.c++
Subject: Re: labels at the end of a function
Date: Tue, 30 Aug 2022 20:15:03 +0200
Organization: Aioe.org NNTP Server
Message-ID: <telk39$1osb$1@gioia.aioe.org>
References: <tejphm$19h6e$1@dont-email.me>
<cone.1661827324.810372.52241.1004@monster.email-scan.com>
<20220830124652.bab3908329ccf4b6cf52d33d@g{oogle}mail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="58251"; posting-host="2EBed1tE9Z/9AUPY2rndVQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.2.0
Content-Language: fr
X-Notice: Filtered by postfilter v. 0.9.2
 by: Opus - Tue, 30 Aug 2022 18:15 UTC

Le 30/08/2022 à 11:46, Anton Shepelev a écrit :
> Sam:
>
>> The more goto-s get written, the more likely is it for
>> Chulhu to appear and bring humanity to an end.
>
> I disagree. Structured use of GOTO's (the topic of a Knuch
> article!), especially when they jump down and nest stack-
> like can greately simplify certain code structures. They
> help to avoid returns from mid-function, and let the
> programmer execute common deinitialisation code. My standard
> pattern of error-handling is based on GOTO's:
>
> https://nedbatchelder.com/text/exceptions-vs-status.html#comment_15239

This is a relatively common pattern in C, and I also use it occasionally
(meaning, not in all cases.)

I find it quirky though, and it works for lack of better flow control in
C. Something that is sometimes implemented as "defer" in other languages.

Re: labels at the end of a function

<1c996694-7a1a-41e0-a18a-f67970438bf6n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2807&group=comp.lang.fortran#2807

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:28c5:b0:6bb:b0c9:3053 with SMTP id l5-20020a05620a28c500b006bbb0c93053mr13239979qkp.674.1661886718106;
Tue, 30 Aug 2022 12:11:58 -0700 (PDT)
X-Received: by 2002:a81:f47:0:b0:31f:434b:5ee with SMTP id 68-20020a810f47000000b0031f434b05eemr15256515ywp.383.1661886717919;
Tue, 30 Aug 2022 12:11:57 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Tue, 30 Aug 2022 12:11:57 -0700 (PDT)
In-Reply-To: <tel7o3$raj7$1@news.xmission.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:9436:1cc2:ea0:7fd3;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:9436:1cc2:ea0:7fd3
References: <tejphm$19h6e$1@dont-email.me> <99oPK.21145$6Il8.5192@fx14.iad> <tel7o3$raj7$1@news.xmission.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1c996694-7a1a-41e0-a18a-f67970438bf6n@googlegroups.com>
Subject: Re: labels at the end of a function
From: gah4@u.washington.edu (gah4)
Injection-Date: Tue, 30 Aug 2022 19:11:58 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 7
 by: gah4 - Tue, 30 Aug 2022 19:11 UTC

On Tuesday, August 30, 2022 at 7:44:23 AM UTC-7, Kenny McCormack wrote:

(snip)

> P.S. Why is this also posted to a Fortran group?

I believe it was accidental, but since you could call it
with the C interoperability feature, it might be applicable.

Re: labels at the end of a function

<telu8p$1iiha$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2809&group=comp.lang.fortran#2809

  copy link   Newsgroups: comp.lang.c comp.lang.fortran comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: lynnmcguire5@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.c,comp.lang.fortran,comp.lang.c++
Subject: Re: labels at the end of a function
Date: Tue, 30 Aug 2022 16:08:40 -0500
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <telu8p$1iiha$1@dont-email.me>
References: <tejphm$19h6e$1@dont-email.me> <99oPK.21145$6Il8.5192@fx14.iad>
<tel7o3$raj7$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 30 Aug 2022 21:08:41 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="f62188411efda3fa75a445186dfcdd7e";
logging-data="1657386"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+x+hUmv5eWzMNqLo1ww2jD"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.2.0
Cancel-Lock: sha1:XGo4FpLx8g8CPYuDorZpN7JZeX4=
Content-Language: en-US
In-Reply-To: <tel7o3$raj7$1@news.xmission.com>
 by: Lynn McGuire - Tue, 30 Aug 2022 21:08 UTC

On 8/30/2022 9:44 AM, Kenny McCormack wrote:
> In article <99oPK.21145$6Il8.5192@fx14.iad>,
> Scott Lurndal <slp53@pacbell.net> wrote:
>> Lynn McGuire <lynnmcguire5@gmail.com> writes:
>>> 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 ?
>>
>> Your function is missing a return statement.
>
> Or they misspelled "void" as "int".
>
> P.S. Why is this also posted to a Fortran group?

Because I typed comp.lang.c into Thunderbird and Thunderbird graciously
also put comp.lang.fortran in there for me which I did not notice.

Lynn

Re: labels at the end of a function

<telv5u$h0f$2@newsreader4.netcologne.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2810&group=comp.lang.fortran#2810

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-4e56-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: labels at the end of a function
Date: Tue, 30 Aug 2022 21:24:14 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <telv5u$h0f$2@newsreader4.netcologne.de>
References: <tejphm$19h6e$1@dont-email.me> <99oPK.21145$6Il8.5192@fx14.iad>
<tel7o3$raj7$1@news.xmission.com>
<1c996694-7a1a-41e0-a18a-f67970438bf6n@googlegroups.com>
Injection-Date: Tue, 30 Aug 2022 21:24:14 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-4e56-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:4e56:0:7285:c2ff:fe6c:992d";
logging-data="17423"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Tue, 30 Aug 2022 21:24 UTC

gah4 <gah4@u.washington.edu> schrieb:
> On Tuesday, August 30, 2022 at 7:44:23 AM UTC-7, Kenny McCormack wrote:
>
> (snip)
>
>> P.S. Why is this also posted to a Fortran group?
>
> I believe it was accidental, but since you could call it
> with the C interoperability feature, it might be applicable.

Fortran has no problem with labels at the end of subroutines
or functions. This is legal:

subroutine a
goto 100
100 end subroutine a

although good style would seem to advise

subroutine a
goto 100
100 continue
end subroutine a

(The "continue" statement is a do-nothing placeholder).

Re: labels at the end of a function

<19f9fe2d-48e7-4490-a0a9-99c03736eacfn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2811&group=comp.lang.fortran#2811

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:11d2:b0:343:67a1:85e8 with SMTP id n18-20020a05622a11d200b0034367a185e8mr16761033qtk.11.1661895555345;
Tue, 30 Aug 2022 14:39:15 -0700 (PDT)
X-Received: by 2002:a05:6902:124e:b0:668:222c:e8da with SMTP id
t14-20020a056902124e00b00668222ce8damr13215411ybu.383.1661895555206; Tue, 30
Aug 2022 14:39:15 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Tue, 30 Aug 2022 14:39:14 -0700 (PDT)
In-Reply-To: <telv5u$h0f$2@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:68bf:720b:6eba:2a6d;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:68bf:720b:6eba:2a6d
References: <tejphm$19h6e$1@dont-email.me> <99oPK.21145$6Il8.5192@fx14.iad>
<tel7o3$raj7$1@news.xmission.com> <1c996694-7a1a-41e0-a18a-f67970438bf6n@googlegroups.com>
<telv5u$h0f$2@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <19f9fe2d-48e7-4490-a0a9-99c03736eacfn@googlegroups.com>
Subject: Re: labels at the end of a function
From: gah4@u.washington.edu (gah4)
Injection-Date: Tue, 30 Aug 2022 21:39:15 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2185
 by: gah4 - Tue, 30 Aug 2022 21:39 UTC

On Tuesday, August 30, 2022 at 2:24:18 PM UTC-7, Thomas Koenig wrote:

(snip)

> Fortran has no problem with labels at the end of subroutines
> or functions. This is legal:
> subroutine a
> goto 100
> 100 end subroutine a
> although good style would seem to advise
> subroutine a
> goto 100
> 100 continue
> end subroutine a
> (The "continue" statement is a do-nothing placeholder).

It didn't always do that.

In Fortran 66, and I believe 77, END is a non-executable statement.
You are supposed to have STOP or RETURN (or GOTO) before it.

I suspect many allowed one to skip the STOP or RETURN, but
still no label on END.

In any case, the C function with type other than void should have a
return with appropriate type. Compilers will usually give warning
or error if you don't. And then you can label the return.

Re: labels at the end of a function

<20220831010425.b666d2bb44c00232160a567c@gmail.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2812&group=comp.lang.fortran#2812

  copy link   Newsgroups: comp.lang.c comp.lang.fortran comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: anton.txt@gmail.com (Anton Shepelev)
Newsgroups: comp.lang.c,comp.lang.fortran,comp.lang.c++
Subject: Re: labels at the end of a function
Date: Wed, 31 Aug 2022 01:04:25 +0300
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <20220831010425.b666d2bb44c00232160a567c@gmail.com>
References: <tejphm$19h6e$1@dont-email.me>
<99oPK.21145$6Il8.5192@fx14.iad>
<tel7o3$raj7$1@news.xmission.com>
<telu8p$1iiha$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="91a7edbd58b05c83f6d3e0aa63040da2";
logging-data="1669605"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+K4ihaAtJF63Jdoz++1MnqM/X9RAY9b7E="
Cancel-Lock: sha1:+FVk4nGemn0zIlhKYxwH5sO6UhI=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Tue, 30 Aug 2022 22:04 UTC

Lynn McGuire to Kenny McCormack:

> > P.S. Why is this also posted to a Fortran group?
>
> Because I typed comp.lang.c into Thunderbird and
> Thunderbird graciously also put comp.lang.fortran in there
> for me which I did not notice.

Amazing grace. Did you mean `gratuitiously'?

Re: labels at the end of a function

<temdh1$1jse3$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2815&group=comp.lang.fortran#2815

  copy link   Newsgroups: comp.lang.c comp.lang.fortran comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: lynnmcguire5@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.c,comp.lang.fortran,comp.lang.c++
Subject: Re: labels at the end of a function
Date: Tue, 30 Aug 2022 20:29:04 -0500
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <temdh1$1jse3$1@dont-email.me>
References: <tejphm$19h6e$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 31 Aug 2022 01:29:05 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="9b89ccd33ec3631a6cdb25311d3650d9";
logging-data="1700291"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19kb6rHJJDT0Gmq3qAU6NK0"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.2.0
Cancel-Lock: sha1:O3Y9EfrSoxXnUIL3RpLGQSlHYhA=
In-Reply-To: <tejphm$19h6e$1@dont-email.me>
Content-Language: en-US
 by: Lynn McGuire - Wed, 31 Aug 2022 01:29 UTC

On 8/29/2022 8:35 PM, Lynn McGuire 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 ?
>
> Thanks,
> Lynn

Thanks to all ! I now understand a little bit better. I've been
programming in Fortran for 47 years, C for 35 years, and C++ for 20
years. I always like learning a little bit more about each.

Lynn

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor