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


Groups > comp.lang.c > #105752

Re: Return statement: anything goes?

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Return statement: anything goes?
Date 2017-03-10 12:34 -0800
Organization None to speak of
Message-ID <lny3wcg9al.fsf@kst-u.example.com> (permalink)
References <o9utno$5tn$1@dont-email.me> <0a96e294-bd5c-4a52-9519-9f4748750cf2@googlegroups.com>

Show all headers | View raw


John Bode <jfbode1029@gmail.com> writes:
[...]
> B4, C3, and M4 - I'm not sure.  6.8.6.4 says that values of types different
> from the return type are converted as if by assignment, so I'd expect
> a diagnostic if the expression type and the return type aren't compatible.
> Footnote 160 says that since the return statement is *not* an assignment,
> the overlap restriction of 6.5.16.1 doesn't apply.

Type *compatibility* is not the issue.  The term is sometimes
incorrectly used to refer to types that can be implicitly converted to
each other, but that's not what it means.  Basically, two types are
"compatible" only if they're the same type, or in a few other cases.

The types that can be implicitly converted to each other are described
in the standard under simple assignment.  The same rules apply to
initialization, argument passing, and the return statement.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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


Thread

Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-10 19:13 +0000
  Re: Return statement: anything goes? John Bode <jfbode1029@gmail.com> - 2017-03-10 11:59 -0800
    Re: Return statement: anything goes? Keith Thompson <kst-u@mib.org> - 2017-03-10 12:34 -0800
  Re: Return statement: anything goes? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-10 20:17 +0000
    Re: Return statement: anything goes? bart4858@gmail.com - 2017-03-10 13:17 -0800
      Re: Return statement: anything goes? Ian Collins <ian-news@hotmail.com> - 2017-03-11 10:30 +1300
      Re: Return statement: anything goes? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-11 01:25 +0000
        Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-11 12:11 +0000
          Re: Return statement: anything goes? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-11 14:57 +0000
            Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-11 16:31 +0000
              Re: Return statement: anything goes? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-11 17:47 +0000
                Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-11 17:57 +0000
                Re: Return statement: anything goes? jameskuyper@verizon.net - 2017-03-11 10:59 -0800
                Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-11 19:34 +0000
                Re: Return statement: anything goes? jameskuyper@verizon.net - 2017-03-11 11:59 -0800
                Re: Return statement: anything goes? supercat@casperkitty.com - 2017-03-11 12:26 -0800
                Re: Return statement: anything goes? supercat@casperkitty.com - 2017-03-11 12:22 -0800
                Re: Return statement: anything goes? jameskuyper@verizon.net - 2017-03-11 12:42 -0800
                Re: Return statement: anything goes? supercat@casperkitty.com - 2017-03-11 13:01 -0800
                Re: Return statement: anything goes? Gordon Burditt <gordon@hammy.burditt.org> - 2017-03-13 16:25 -0500
            Re: Return statement: anything goes? Gareth Owen <gwowen@gmail.com> - 2017-03-11 16:43 +0000
              Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-11 18:13 +0000
                Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-11 18:27 +0000
          Re: Return statement: anything goes? gordonb.rlpr3@burditt.org (Gordon Burditt) - 2017-03-13 16:18 -0500
        Re: Return statement: anything goes? supercat@casperkitty.com - 2017-03-11 12:44 -0800
      Re: Return statement: anything goes? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-03-11 07:43 -0800
        Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-11 18:34 +0000
          Re: Return statement: anything goes? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-03-11 10:43 -0800
  Re: Return statement: anything goes? Keith Thompson <kst-u@mib.org> - 2017-03-10 12:27 -0800
  Re: Return statement: anything goes? Noob <root@127.0.0.1> - 2017-03-10 22:06 +0100
    Re: Return statement: anything goes? bart4858@gmail.com - 2017-03-10 13:26 -0800
      Re: Return statement: anything goes? antispam@math.uni.wroc.pl - 2017-03-12 05:29 +0000
        Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-12 10:52 +0000
          Re: Return statement: anything goes? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-12 12:19 +0000
            Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-12 12:51 +0000

csiph-web