From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by sourceware.org (Postfix) with ESMTPS id D9A433858D33 for ; Thu, 11 May 2023 07:42:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D9A433858D33 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=aarsen.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=aarsen.me Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4QH3ky0tdpz9slK; Thu, 11 May 2023 09:42:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aarsen.me; s=MBO0001; t=1683790938; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5ZQG5TN9bydNa91cVu7QiWQAobHlUUBmbI0hykDprpM=; b=LHL1WPIPBGC207RP1FY/EUSL+0fkAB0MupelivVQz90bKIB0AzEvMhpVrF4oM/DXAL6b0d jwAiR8DEFvUEPhUls6/oeokF2B0R590c07ruQnIZwTDxHGb/Uo8pMSmk+O1xcwuEA61DKB 80FbOPUnYUN/7vCB+1vA8tSLemfwOQ17fzpRpMaxStZU/96HtwbuYzNCI6+RkTGiq+KKlq DszpyYM5SnJnr0cDE9KH9zpkAm51+ohoDtCcZ4PW/sXCvoyUXN8pVNd77mrWCz5JOAzbFU nlvnPg1ds+bqg5xGWISckZgn7FKtBX6t4+c9bXWJn08W/MTOVn47ZzICUP/K3Q== References: <877cth66qb.fsf@oldenburg.str.redhat.com> <20230509102201.6aa2a7d14fdb2f1e7abff449@killthe.net> <87r0rp5uf8.fsf@aarsen.me> <83ttwla1ep.fsf@gnu.org> <83lehx9vix.fsf@gnu.org> <83fs859unu.fsf@gnu.org> <87y1lx1avj.fsf@oldenburg.str.redhat.com> <83ednoapb6.fsf@gnu.org> <875y8zegnc.fsf@yahoo.com> From: Arsen =?utf-8?Q?Arsenovi=C4=87?= To: Po Lu Cc: Jonathan Wakely , gcc@gcc.gnu.org Subject: Re: More C type errors by default for GCC 14 Date: Thu, 11 May 2023 09:38:59 +0200 In-reply-to: <875y8zegnc.fsf@yahoo.com> Message-ID: <865y8zmi08.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_INFOUSMEBIZ,KAM_NUMSUBJECT,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Po Lu via Gcc writes: > Jonathan Wakely via Gcc writes: > >> On Wed, 10 May 2023, 03:32 Eli Zaretskii, wrote: >> >>> >>> And then people will start complaining about GCC unnecessarily >>> erroring out, which is a compiler bug, since there's no problem >>> producing correct code in these cases. >>> >> >> >> What is the correct code for this? >> >> void foo(int); >> void bar() { foo("42"); } >> >> Why should this compile? > > Because keeping that from compiling will also keep this from compiling: > > bar () > { > extern foo (); > > return foo ("42"); > } Good. The above code is nonsense, the chances that foo will be incorrectly called are high. >> You keep demanding better rationale for the change, but your argument >> amounts to nothing more than "it compiles today, it should compile >> tomorrow". > > And so it should. Because for every invalid piece of code you can think > of, there are hundereds or thousands of combinations that may as well be > valid. For example, on the 68020, vax, or similarly reasonable 32-bit > machine: > > foo (ptr) > { > register char *str; > > str =3D ptr; > > /* do stuff with str */ > > puts (str); > } > > /* In another translation unit. */ > > bar () > { > foo ("42"); > } What is this meant to produce? This is, at best, a "works by coincidence", rather than being code anyone should be writing. Such code is already written, when building it, pass -fpermissive. You benefit from the error otherwise. (and no, this isn't an issue of style, the code in question *does not* convey sufficient information for the compiler to always do the right thing) Have a lovely day. =2D-=20 Arsen Arsenovi=C4=87 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iOYEARYKAI4WIQT+4rPRE/wAoxYtYGFSwpQwHqLEkwUCZFycWF8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0RkVF MkIzRDExM0ZDMDBBMzE2MkQ2MDYxNTJDMjk0MzAxRUEyQzQ5MxAcYXJzZW5AYWFy c2VuLm1lAAoJEFLClDAeosSTjOsA/2aE2M2jnZ5BAP/f2Hc3Iy6AFRsXqGgpCGIf xHS43A8pAP9MI7zqTmjermeL33pw1pNep+W01E8Rne5XKDVS1UmTAg== =c1zd -----END PGP SIGNATURE----- --=-=-=--