Sujet : Re: Casting the return value of ...
De : 433-929-6894 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 28. Mar 2024, 22:44:28
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240328142950.542@kylheku.com>
References : 1 2 3 4 5
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-03-28, Keith Thompson <Keith.S.Thompson+
u@gmail.com> wrote:
The warnings I get from gcc are:
>
warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
warning: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic]
>
With -pedantic-errors, these become fatal errors.
>
I disagree with gcc. ISO C doesn't define the behavior, but it doesn't
forbid the conversion.
It's never good for a diagnostic to be stating a blatant falsehood,
regardless of whether the presence of the diagnostic is a good idea
or not.
There is a problem in the man page also (haven't checked the main doc):
Issue all the warnings demanded by strict ISO C and ISO C++;
reject all programs that use forbidden extensions, and some
other programs that do not follow ISO C and ISO C++. For ISO C,
follows the version of the ISO C standard specified by any -std
option used.
There are no "forbidden extensions"! There are extensions we have,
and extensions we don't have. Extensions we don't have a undefined
behavior.
The misconception is repeated in the GNU Conding Conventions. It might
have come from the same person.
https://www.gnu.org/prep/standards/standards.html But we do not follow either of these specifications rigidly, and
there are specific points on which we decided not to follow them, so
as to make the GNU system better for users.
For instance, Standard C says that nearly all extensions to C are
prohibited. How silly! GCC implements many extensions, some of which
were later adopted as part of the standard. If you want these
constructs to give an error message as “required” by the standard,
you must specify ‘--pedantic’, which was implemented only so that we
can say “GCC is a 100% implementation of the standard”, not because
there is any reason to actually use it.
Standard C does not say that any extensions are prohibited.
How silly to think so, and write about it, and code a facet of the
compiler diagnostic system that way!
I'm actually opening a GCC bugzilla about this right now.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca