Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | pembed2012 <once@was.enough.invalid> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Redundant return() |
| Date | 2012-05-14 16:40 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <jorci2$5pa$1@speranza.aioe.org> (permalink) |
| References | <jomldo$t8f$1@speranza.aioe.org> <m0qtq7tombg6lrdkvk47hsodp6i39i9jut@4ax.com> |
On Sat, 12 May 2012 15:49:57 -0700, Barry Schwarz wrote:
> On Sat, 12 May 2012 21:41:12 +0000 (UTC), pembed2012
> <once@was.enough.invalid> wrote:
>
>>I have seen redundant return statements at the end of function. IE.
>> init_function()
>> {
>> a_init();
>> b_init();
>> c_init();
>> return();
>
> ITYM return;
>
>> }
>>I checked the generated code in GCC Compiler 3.2.2 on Red Hat Linux it
>>is ignored so it not harmful to use this.
>>
>>Has anybody got any problem/issues with this on any compiler/platform?
>
> Some organizations have coding standards which require each function to
> have exactly one explicit return at the end of the function. It
> simplifies maintenance if the type or presence of a return value needs
> to be changed during a software update.
>
> I wonder what kind of problem you envision. At worst, a brain dead
> compiler could generate instructions for the return statement and then a
> second set of (duplicate?) instructions for the implied return at the
> closing brace.
Ho, you are right, I can invoke the return function with no () and there
is no compiler error. Wired.
I thought in a VOID function it will be an error to invoke return, maybe
clobber the place in the stack that would store a return val in a non-
VOID function etc.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Redundant return() pembed2012 <once@was.enough.invalid> - 2012-05-12 21:41 +0000
Re: Redundant return() pembed2012 <once@was.enough.invalid> - 2012-05-12 21:56 +0000
Re: Redundant return() Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-05-12 17:07 -0600
Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-12 18:46 -0400
Re: Redundant return() Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-05-12 20:10 -0400
Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-12 21:29 -0400
Re: Redundant return() Barry Schwarz <schwarzb@dqel.com> - 2012-05-12 15:49 -0700
Re: Redundant return() pembed2012 <once@was.enough.invalid> - 2012-05-14 16:40 +0000
Re: Redundant return() Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-05-14 17:57 +0100
Re: Redundant return() nick_keighley_nospam@hotmail.com - 2012-05-15 00:33 -0700
Re: Redundant return() nick_keighley_nospam@hotmail.com - 2012-05-15 03:03 -0700
Re: Redundant return() nick_keighley_nospam@hotmail.com - 2012-05-15 03:26 -0700
Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-15 08:51 -0400
Re: Redundant return() "BartC" <bc@freeuk.com> - 2012-05-15 12:20 +0100
Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 07:59 +1200
Re: Redundant return() Kaz Kylheku <kaz@kylheku.com> - 2012-05-15 20:08 +0000
Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 08:18 +1200
Re: Redundant return() Lanarcam <lanarcam1@yahoo.fr> - 2012-05-15 22:48 +0200
Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 09:56 +1200
Re: Redundant return() "BartC" <bc@freeuk.com> - 2012-05-15 22:59 +0100
Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 10:16 +1200
Re: Redundant return() "BartC" <bc@freeuk.com> - 2012-05-16 09:29 +0100
Re: Redundant return() Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-05-15 07:51 -0400
Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-15 08:47 -0400
Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 08:01 +1200
Re: Redundant return() "BartC" <bc@freeuk.com> - 2012-05-15 22:58 +0100
Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 10:24 +1200
Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-15 18:39 -0400
Re: Redundant return() nick_keighley_nospam@hotmail.com - 2012-05-16 02:45 -0700
Re: Redundant return() Noob <root@127.0.0.1> - 2012-05-16 13:34 +0200
csiph-web