Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Const-qualified function return type in C - is it a part of function type?
Date: Mon, 24 Feb 2020 20:58:12 -0800
Organization: A noiseless patient Spider
Lines: 84
Message-ID: <86blpnb6vv.fsf@linuxsc.com>
References: <45853431-d208-46e0-8945-78a42ed1a83e@googlegroups.com> <8736b2aeib.fsf@bsb.me.uk> <86wo8ebion.fsf@linuxsc.com> <87o8tq71zo.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="736228d0aa4bff80edfe6f310ec1eb3b"; logging-data="18257"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hTqTZ3g60+Bg4iUZ2aCCz55QQJF20sHY="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:9mNgINA4OyqiQD2ShLeyvzYf6I4= sha1:bFxFmQ/QrxkDfCQKO3l4qz3sGNg=
Xref: csiph.com comp.lang.c:150212
Ben Bacarisse writes:
> Tim Rentsch writes:
>
>> Ben Bacarisse writes:
>>
>>> Andrey Tarasevich writes:
>>>
>>>
>>>> To avoid any further wastage of time on this irrelevant matter I
>>>> hereby postulate one more time: the above quoted passage refers to
>>>> qualifiers applied to the function type itself (which, BTW, is only
>>>> possible through typedef names).
>>>
>>> And interesting detail, which I can't interpret... In all versions of
>>> the C standard, there is a footnote attached to the paragraph
>>>
>>> "If the specification of an array type includes any type qualifiers,
>>> the element type is so qualified, not the array type. If the
>>> specification of a function type includes any type qualifiers, the
>>> behavior is undefined."
>>>
>>> In C90, this footnote seems to be:
>>>
>>> 59) Both of these can only occur through the use of typedefs.
>>>
>>> By C99 it appears to have become
>>>
>>> 118) Both of these can occur through the use of typedefs.
>>>
>>> Why the change I wonder?
>>
>> I believe it was prompted by point 8 in this document, written by
>> Doug Gwyn (dated 1997):
>>
>> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n762.htm
>
> Which says:
>
> 8. erroneous footnote 82
>
> 8.1 the_problem
>
> Footnote 82 erroneously says that only through the use of
> typedefs can array or function type specifications include
> any type qualifiers.
>
> 8.2 my_opinion
>
> I think this footnote was trying to be helpful, but
> incorrect footnotes are not helpful.
>
> 8.3 my_proposal
>
> In 6.5.3 Type qualifiers, delete Footnote 82 and the
> reference to it.
>
>>> Is there a way to qualify a function or array
>>> type without a typedef? I can't see one.
>>
>> I believe there is not. My guess is Doug was confused about what
>> the footnoted sentence was meant to say, which in turn led him to
>> misinterpret the footnote.
>
> What a strange state of affairs. The original is helpful precisely
> because of the one word that got removed.
Personally I find the footnote helpful either with or without the
word 'only'. For me the 'only' doesn't add much, if indeed it
adds anything helpful at all.
> And I can't see why n762 caused the vital word to be removed.
Probably because, as Doug was a member of long standing, and very
much involved in working on the Standard, he was taken at his
word that something about the footnote was inaccurate. At the
same time it was realized that it isn't obvious how to construct
such qualified types, so the footnote was left in, in a modified
form, to help with that.
The previous paragraph is speculation on my part, so take it for
what it is worth. I don't have any evidence to point to in
support of that speculation.