Deutsch English Français Italiano |
<877chmt23h.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.lang.c Subject: Re: Casting the return value of ... Date: Thu, 28 Mar 2024 15:37:22 -0700 Organization: None to speak of Lines: 44 Message-ID: <877chmt23h.fsf@nosuchdomain.example.com> References: <uu416t$33u55$1@news.xmission.com> <20240328105203.773@kylheku.com> <87frwatadu.fsf@nosuchdomain.example.com> <uu4k1c$3pq71$1@dont-email.me> <87bk6yt68v.fsf@nosuchdomain.example.com> <20240328142950.542@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Thu, 28 Mar 2024 22:37:26 +0100 (CET) Injection-Info: dont-email.me; posting-host="2dfbf40368bf600f73fcb17ce635941b"; logging-data="4051192"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188lkDH6aStEoLMJHydXngX" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:pl94fXoV0akPKONf2HCdTiEslbQ= sha1:a+AonyASiQGcWoDVgufEgLRBYTc= Bytes: 2862 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 */