Re: Casting the return value of ...

Liste des GroupesRevenir à l c 
Sujet : Re: Casting the return value of ...
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.c
Date : 29. Mar 2024, 00:37:22
Autres entêtes
Organisation : None to speak of
Message-ID : <877chmt23h.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Kaz Kylheku <433-929-6894@kylheku.com> writes:
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.
[...]
I'm actually opening a GCC bugzilla about this right now.

I should have remembered that I reported this as a bug in 2017:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83584

That bug report was closed (inappropriately IMHO) as a duplicate of

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11234

A commenter on bug #83584 cites the C99 Rationale:
"Even with an explicit cast, it is invalid to convert a function pointer
to an object pointer or a pointer to void, or vice versa."

It's not clear what "invalid" means in that context, and in any case the
Rationale is not normative.

N1570 Annex J 5.7 mentions casting between object pointers and function
pointers as a common extension.

Kaz, I see you've submitted
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114526
which has (inappropriately IMHO) been closed as a duplicate of #11234.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Date Sujet#  Auteur
28 Mar 24 * Casting the return value of ...31Kenny McCormack
28 Mar 24 +* Re: Casting the return value of ...27Kaz Kylheku
28 Mar 24 i+* Re: Casting the return value of ...20Keith Thompson
28 Mar 24 ii`* Re: Casting the return value of ...19bart
28 Mar 24 ii +* Re: Casting the return value of ...12Keith Thompson
28 Mar 24 ii i+- Re: Casting the return value of ...1Chris M. Thomasson
28 Mar 24 ii i+* Re: Casting the return value of ...8Kaz Kylheku
29 Mar 24 ii ii+* Re: Casting the return value of ...5Kaz Kylheku
29 Mar 24 ii iii`* Re: Casting the return value of ...4Kaz Kylheku
29 Mar 24 ii iii `* Re: Casting the return value of ...3Michael S
29 Mar 24 ii iii  `* gcc Bugzilla search (was: Casting the return value of ...)2Michael S
29 Mar 24 ii iii   `- Re: gcc Bugzilla search1David Brown
29 Mar 24 ii ii+- Re: Casting the return value of ...1Keith Thompson
8 Jun 24 ii ii`- Re: Casting the return value of ...1Tim Rentsch
29 Mar 24 ii i`* Re: Casting the return value of ...2David Brown
30 Mar 24 ii i `- Re: Casting the return value of ...1Chris M. Thomasson
29 Mar 24 ii `* Re: Casting the return value of ...6David Brown
29 Mar 24 ii  `* Re: Casting the return value of ...5bart
29 Mar 24 ii   +- Re: Casting the return value of ...1David Brown
30 Mar 24 ii   `* Re: Casting the return value of ...3Tim Rentsch
30 Mar 24 ii    `* Re: Casting the return value of ...2bart
9 Apr 24 ii     `- Re: Casting the return value of ...1Tim Rentsch
30 Mar 24 i`* Re: Casting the return value of ...6Tim Rentsch
31 Mar 24 i +* Re: Casting the return value of ...3Lawrence D'Oliveiro
31 Mar 24 i i+- Re: Casting the return value of ...1David Brown
31 Mar 24 i i`- Re: Casting the return value of ...1Chris M. Thomasson
9 Apr 24 i `* Re: Casting the return value of ...2Tim Rentsch
9 Apr 24 i  `- Re: Casting the return value of ...1David Brown
29 Mar 24 +* Re: Casting the return value of ...2Andrey Tarasevich
29 Mar 24 i`- Re: Casting the return value of ...1Keith Thompson
30 Mar 24 `- Re: Casting the return value of ...1Tim Rentsch

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal