Article View: comp.lang.c++
Article #111Re: “The end of software secrecy is almost upon
From: Charlie Gibbs
Date: Tue, 20 Oct 2026 23:18
Date: Tue, 20 Oct 2026 23:18
37 lines
2939 bytes
2939 bytes
On 2026-10-20, Lawrence D’Oliveiro <ldo@nz.invalid> wrote: > On Tue, 20 Oct 2026 19:04:55 GMT, Charlie Gibbs wrote: > >> The undisciplined use of GOTOs is bad, agreed. > > Is there such a thing as a *disciplined* use of gotos? Yes, especially in COBOL or assembly language. For instance, a GOTO to the end of a function ensures any of its cleanup code gets executed, and fulfils a goal of structured proramming: each function has one exit point. > I find the C code I write tends to do a lot of dynamic resource > allocations. These can sometimes fail with errors. So error recovery > will invariably involve cleaning up those parts of the allocations > which already succeeded. Gotos are no good for this; you need to exit > levels of structure nesting one by one, disposing of allocations as > you go. I know that a lot of CS types are going to stick pins into little dolls that look like me for saying this, but IMHO resource pointers, handles, etc. should be global. Possible exceptions are resources that are going to be used solely by the current function - but even then, if that function calls another function that fails horribly, there's stuff that might not get cleaned up. That's why all my C programs contain a function quit_cleanup(char *errmsg), which de-allocates all resources and then exits (displaying "errmsg" if it isn't NULL). I can call that function anywhere, safe in the knowledge that by the time it finishes (it never returns), everything will have be freed. -- /~\ Charlie Gibbs | In this world there are \ / <cgibbs@kltpzyxm.invalid> | two kinds of people: X I'm really at ac.dekanfrus | 1. Those who can extrapolate / \ if you read it the right way. | from incomplete data.
Technical Details
Message-ID:
<oFSBS.93666$Q3f.6740@fx05.iad>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer05.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx05.iad.POSTED!not-for-mailReferences:
<11amvre$15far$1@dont-email.me> <11b5tdb$2cs5l$1@dont-email.me> <11b64cp$end$1@panix2.panix.com> <11b64hj$2faos$1@dont-email.me> <11b679m$6dl$1@panix2.panix.com> <11b6u68$2neta$1@dont-email.me> <11b6v90$2nine$3@dont-email.me> <11b87t8$379mv$1@dont-email.me> <11b8b2k$p44i$1@dont-email.me> <rXOBS.7015$5Iy.3911@fx04.iad> <11b8h83$3b48o$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer05.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx05.iad.POSTED!not-for-mail Newsgroups: comp.lang.fortran,comp.lang.c++,alt.comp.lang.rust,alt.folklore.computers From: Charlie Gibbs <cgibbs@kltpzyxm.invalid> Subject: Re: “The end of software secrecy is almost upon References: <11amvre$15far$1@dont-email.me> <11b5tdb$2cs5l$1@dont-email.me> <11b64cp$end$1@panix2.panix.com> <11b64hj$2faos$1@dont-email.me> <11b679m$6dl$1@panix2.panix.com> <11b6u68$2neta$1@dont-email.me> <11b6v90$2nine$3@dont-email.me> <11b87t8$379mv$1@dont-email.me> <11b8b2k$p44i$1@dont-email.me> <rXOBS.7015$5Iy.3911@fx04.iad> <11b8h83$3b48o$1@dont-email.me> User-Agent: slrn/1.0.3 (Linux) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lines: 37 Message-ID: <oFSBS.93666$Q3f.6740@fx05.iad> X-Complaints-To: https://www.astraweb.com/aup NNTP-Posting-Date: Tue, 20 Oct 2026 23:18:44 UTC Date: Tue, 20 Oct 2026 23:18:44 GMT X-Received-Bytes: 2746