Sujet : Re: Casting the return value of ...
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 28. Mar 2024, 20:38:21
Autres entêtes
Organisation : None to speak of
Message-ID : <87frwatadu.fsf@nosuchdomain.example.com>
References : 1 2
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Kaz Kylheku <
433-929-6894@kylheku.com> writes:
[...]
Conversions between function pointers and data pointers are an
extension; it is not well-defined behavior in ISO C.
>
Therefore we can neither say that ISO C doesn't require a cast there (it
imposes no requirements at all), nor that the conversion is fine with a
cast.
>
The cast is /likely/ necessary, in order to correctly trigger the
extension.
ISO C does require a cast. The cast is necessary to avoid a constraint
violation and a mandatory diagnostic. The resulting behavior is
undefined in ISO C, but defined by POSIX.
Assigning a void* value to a pointer-to-function object without a cast
violates the constraint for simple assignment (N1570 6.5.16.1p1).
[...]
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comWorking, but not speaking, for Medtronicvoid Void(void) { Void(); } /* The recursive call of the void */