From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 082353858D20; Thu, 28 Mar 2024 22:00:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 082353858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711663221; bh=6Z6dabkB/xhj86+HDXLRzpBs4fV65aZxp8rSjxbpP/g=; h=From:To:Subject:Date:From; b=dUGHu6Asco4dEbinvp9jUGEL33ynzdJ3FAniP1ts/909V8HtVi+mFCO0zkiAydA/9 UjmW5rZ59unYk9IuiSgEI4D+RFmMkZ0sXnTmgHaAehF/BJXo0JQ+O/x/18hIZYURgd bpJYZZHmC5Z3CMkTb+Btw2aEDYwaofkuDpCHVHqc= From: "kkylheku at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/114526] New: ISO C does not prohibit extensions: fix misconception. Date: Thu, 28 Mar 2024 22:00:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: UNCONFIRMED X-Bugzilla-Resolution: 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 Bug ID: 114526 Summary: ISO C does not prohibit extensions: fix misconception. Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: kkylheku at gmail dot com Target Milestone: --- There seems to be a historic misconception in the development of GCC that t= he C standard prohibits extensions. The -Wpedantic/-pedantic options are unfortunately organized around this false idea. Firstly, for a bit of background, in the GNU Coding Standards document we h= ave this: > 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 > =E2=80=9Crequired=E2=80=9D by the standard, you must specify =E2=80=98--p= edantic=E2=80=99, > which was implemented only so that we can say =E2=80=9CGCC is a 100% > implementation of the standard=E2=80=9D, not because there is any > reason to actually use it.=20 [https://www.gnu.org/prep/standards/standards.html] I suspect this might have been written, at some point, by someone actually working on the design of GCC. Or at least believing the GCC documentation. The GCC man page contains text which propagates the same falsehood, claiming that the -Wpedantic/-pedantic options "[i]ssue 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++." The same text appears in the main documentation. This is false; there are no forbidden extensions. There are conforming extensions and nonconforming extensions. Nonconforming extensions are those that require a diagnostic if interpreted as ISO C, due to using new syntax = or anything else diagnosable. Probably, -pedantic mode should only stick to emitting required diagnostics. For instance if program uses a nonconforming extension then -pedantic should cause that to be diagnosed (while continuing to accept the GNU extension, if it's just a warning). The following diagnostics have a wording which perpetrates the falsehood th= at extensions are forbidden: > warning: ISO C forbids conversion of function pointer to object pointer t= ype [-Wpedantic] > warning: ISO C forbids conversion of object pointer to function pointer t= ype [-Wpedantic] ISO C forbids no not such thing, and requires no diagnostic.=20 It is a conforming extension in GCC, allowed by the standard, and even requ= ired by POSIX (so that the result of dlsym can be usefully converted to a functi= on pointer). Diagnostics which warn about conforming extensions (and reject programs when warnings are treated as errors) arguably have no place in -pedantic mode. (= They can stand on their own, or be put into some other special category.) The incorrect claims in the documentation should be removed, and pedantic mode's focus should be diagnosing situations where ISO C requires a diagnos= tic but GCC doesn't emit one by default. Wording in diagnostics which claims that ISO C forbids something should likewise be revised; people read these statements and take them to be true!=