From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 837833858D20; Thu, 28 Mar 2024 22:33:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 837833858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711665205; bh=yh5GHo4PWKQHA/uV+r9CNdbmZb4TVnVYitccxepkXkM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=plpL0dtiiPsubAnmz6nSFQcJX1lbNW84QTd64zKz+YqGjFee5/ePmHyxYlo5+DSlm MWk/R7EQQARBs6fzJXIWOJQcvpDEs6r3KEBq9WfsFaNHoT/9RRHxQiuMHlZWG8SKrA W07FtbdBFbyK/M3ANC4JRf0Ubfmdmj8VnNNQLSdQ= From: "kkylheku at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/114526] ISO C does not prohibit extensions: fix misconception. Date: Thu, 28 Mar 2024 22:33:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kkylheku at gmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: DUPLICATE X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114526 --- Comment #3 from Kaz Kylheku --- (In reply to Andrew Pinski from comment #2) > Actually it is a required diagnostic. See PR 11234 for explanation on how. > This was changed a little over 20 years ago explictly to reject this beca= use > it is invalid C. >=20 > *** This bug has been marked as a duplicate of bug 11234 *** This bug report is more than about the specific warning about conversion of function and object pointers. It's about all/any options that don't belong in -pedantic; and about false sentences in diagnostics and documentation. Now, a conversion between a function and object pointer requires no diagnos= tic if the required cast is present. Either way, it is undefined behavior. I'm referencing the N3220 draft. The 6.3 Conversions sections lists, in 6.3.2.3 Pointers, various possible conversions among pointers. Conversions between pointers to object types an= d to function types are not mentioned. It has always been like that going back to ISO C 90 and ANSI C. As an extension, not only is it not forbidden, but it is listed in an Appen= dix as a common extension. In the N3220 draft we have: J.5.8 Function pointer casts A pointer to an object or to void may be cast to a pointer to a function, allowing data to be invoked as a function (6.5.5). A diagnostic is required if a pointer to function is converted to an object pointer, without a cast. 6.5.5 Cast Operators Constraints ... Conversions that involve pointers, other than where permitted by the constraints of 6.5.17.2, shall be specified by means of an explicit cast.= =20=20 If a cast is present, the constraint is satisfied; the conversion is no lon= ger implicit but explicit. No other constraints apply to the conversion. In fac= t no other requirements at all, since it is not defined. GCC provides the common extension described in J.5.8. It is conforming; not= hing needs to be diagnosed about a program which uses it. It, and other extensio= ns, must not be called "forbidden".=