From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by sourceware.org (Postfix) with ESMTPS id 10DD33858D20 for ; Thu, 31 Aug 2023 16:04:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 10DD33858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D3F1FB82336 for ; Thu, 31 Aug 2023 16:04:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33D8EC433C8 for ; Thu, 31 Aug 2023 16:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693497890; bh=9M/09LNTaF2GVq8rK3WGyZ9LFSrpSUtarC4k1idNQ2g=; h=Date:To:From:Subject:From; b=NYkPM2zFYx0afHA0W3f6BCmSgnOmvE6Wz8nhisUB+Ve8dHbTkTfNTjwbY4hjkuYaz HWMIuSL0szAOzp0ijOce1+UTwnyL/lL/3lt5TBtdxNcJ8k/Uuk7rgTtP1SxKh+8s7z 5ZvkcxhGXeFkU/AcD8J+LkGYktZSbOdjEzHclrtUFjsFoF+BzCMe1B1/vr6Lhbs8GH u58sJ2cHSTYW8bQ4x6dXJ5JCCyYof5Cqb6ywvP1Oawgvy2rHcHlf49FUaVfDlcDMxt 4whLkVaTh1Jj9PBLX4rcOmDwoNQ/4qJgn+HrHUqKh9wzReD8eAuLSb6/84se3IF8Jb rk0ve6My4bUkw== Message-ID: Date: Thu, 31 Aug 2023 18:04:42 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.1 Content-Language: en-US To: GCC From: Alejandro Colomar Subject: Confusing location of error in source code Organization: Linux Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------q5xIw98RhcNtpz5XJveYEHaP" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------q5xIw98RhcNtpz5XJveYEHaP Content-Type: multipart/mixed; boundary="------------RhkNDCrZZMVL8xj98rTh1xv0"; protected-headers="v1" From: Alejandro Colomar To: GCC Message-ID: Subject: Confusing location of error in source code --------------RhkNDCrZZMVL8xj98rTh1xv0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi! I've been confused for some time with a compilation error that pointed to a slightly-off location. I wasn't seeing that I used a temporary variable in a constant expression. The code could be reduced to: $ cat const.c=20 int main(void) { int x =3D 42; _Static_assert(0 || 7 > x, ""); } $ cc -Wall -Wextra const.c=20 const.c: In function =E2=80=98main=E2=80=99: const.c:6:26: error: expression in static assertion is not constant 6 | _Static_assert(0 || 7 > x, ""); | ~~^~~~~~~~ I think the appropriate error report should point to this other point: 6 | _Static_assert(0 || 7 > x, ""); | ~~~~~~~~~^ Cheers, Alex --=20 GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5 --------------RhkNDCrZZMVL8xj98rTh1xv0-- --------------q5xIw98RhcNtpz5XJveYEHaP Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmTwuhoACgkQnowa+77/ 2zJv7Q/9EHygBShv/ssrwGzOki3MSBSeeGWQKpaiD27Jfu2To2waNrpVgfySvHta eos1eI6DV7y/uh266Ul4mxkRq/PRWm4KkzFZo4Mh07ybvvuhugEkuHgRTA2Wvmc3 gDpWy6C9EOs3ILvM6C7Og30CO9CVAczFjkAcaq48SE+yxar/Fqpdsh3yQGAxp9fA LIXQW4hBlTJdBNW+2eXn7AnUfhVnscb/pNZNdVrzFy2oKNpia3lDM68xmd74Txj8 ziXFCwiH023aYDRZwTTjZvspdsJ4b/vC393i4phCVK9X/tJq4DV8G2m5xa+i74Tl ifnc0Ca5l9x/+hJM67kGq2By+DxqyOTfNyG9zhmL2QMe1yQzWj4/PExs0g/de3SM lhz7VqfamhZ3JmLJpNmT3PuQH8b4hvf5GZ4RilZeEhLSt139oMIv8OumHUjJSvGr eqtyvzDSIN7vPqQ3Yscge4paZ+rd4FkIEuLK8wDvU0ewKqDWHZGJ9npZ5BFrxoEC Zx3Wc9I04eqQWdYf1Rqmjh+WDpURvuA/5A4GpA+VgnFisgxM7YfSx7HkavZWcgXq 0HIjc8ddo5EtZtn/p3PeSTPB65yvX047Ab4yQe/rypPbc0z6nMB9PCtvZKmOy/uM lCA0BJxjYcp22grCKe8L/cKUGmPSum0oD+Uqsuy+tza5FfIv5M8= =Yhup -----END PGP SIGNATURE----- --------------q5xIw98RhcNtpz5XJveYEHaP--