Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: How to avoid an overflow during multiplication?
Date: Sun, 15 May 2022 07:19:01 -0700
Organization: A noiseless patient Spider
Lines: 71
Message-ID: <861qwu5162.fsf@linuxsc.com>
References: <8735m954yz.fsf@bsb.me.uk> <877dbk36qu.fsf@nosuchdomain.example.com> <86v8ydp57h.fsf@linuxsc.com> <86pmojo7th.fsf@linuxsc.com> <86sfszlsfd.fsf@linuxsc.com> <86ee4hlwrw.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="90fae27f8c3ebf4ec54f5551ea17134b"; logging-data="23066"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ygr97dfYaY0+hJ8LoMvRj3bO6Y4sihYU="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:XkH4ozjJl04BvdRy7qonVCm5bJY= sha1:D7DT++8zhyoswkKoW4CKCkYxeTQ=
Xref: csiph.com comp.lang.c:166166
dave_thompson_2@comcast.net writes:
> (Sorry for delay, I just found this somehow went in a file folder
> instead of outbox)
>
> On Fri, 04 Feb 2022 21:14:59 -0800, Tim Rentsch
> wrote:
>
>> Mateusz Viste writes:
>>
>>> so let me ask: what C99 feature do you use, that you wouldn't want
>>> to loose?
>
> ...
>
>> First there are several constructs that C89/C90 permits but are
>> disallowed in C99:
>
> ...
>
>> * 'return' statements need not give an expression in a
>> function that returns a non-void type, and conversely
>>
>> I understand why K&R C (and later C89/C90) allowed these things.
>
> ...
> Not conversely. return expr in void function was a constraint
> violation in C89/90. (And impossible in K&R which had no void.)
Thank you for the follow-up (and no worries about the delay).
To the best of my knowledge all of the following are true
statements.
K&R C did not have a void type (although some pre-standard C
compilers may have had support for void).
In both the ANSI C standard (C89) and the first ISO C standard
(C90), a return statement with an expression is a constraint
violation if it appears in a function whose return type is void
(although some pre-standard C compilers may not have observed
this rule).
K&R C, C89, and C90 all allow things like this:
int
f(){
...
return;
}
g(){
...
return 0;
}
In the ISO C99 standard, paragraph 5 in the Foreword says (in
part) the following:
This second edition cancels and replaces the first edition,
ISO/IEC 9899:1990, as amended and corrected by ISO/IEC
9899/COR1:1994, ISO/IEC 9899/AMD1:1995, and ISO/IEC
9899/COR2:1996. Major changes from the previous edition
include:
[...]
-- return without expression not permitted in function
that returns a value (and vice versa)
I hope these observations clarify my earlier comment.