From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id D218A4ABF0 for ; Sun, 14 Jul 2024 11:50:38 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 67EAE68D9D1; Sun, 14 Jul 2024 14:50:35 +0300 (EEST) Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BF80B68D969 for ; Sun, 14 Jul 2024 14:50:28 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 1BAE240002 for ; Sun, 14 Jul 2024 11:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1720957828; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=CDWM7qSAPOR+Pn66VdEP2jXF3r7PKQn+oFpbvpY7cdk=; b=fflfrqsOzpQ9y81TfRCMpHDtZhoklVYq9y8St5HLU3lt32m5ZcxZUJUK/O2mYWIx2lsZ2r K6Ey6omcMUi7g03jfhldnVWj51gmt342fXCRSqTxX6tNDiVhQUzLrP7oBRkfbZ6DRvyqiC hsQQ+mIKbkHvYOuKpDrAj3mCYXAcJSHL1H1aFtZYD9HfzSsArOxgrpK1Y7lLyeGMwLOM4r HfIeYWn6qAgDtB8MAByPohKjWsjWNWuopRxnlLQhEsnk/ideSrhJsuRHJ9KmQjOrXosd4p 5v1p5WXtC3sMafXapp41xQBgJq97vI56EG6HALKA++p+k7dHFpPC4JJGD9f7ow== Date: Sun, 14 Jul 2024 13:50:26 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20240714115026.GD4991@pb2> References: <17D4EFB5-C9C8-495C-91D5-81582D94A703@gmail.com> MIME-Version: 1.0 In-Reply-To: <17D4EFB5-C9C8-495C-91D5-81582D94A703@gmail.com> X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 1/3] avutil/avassert: Add av_assert_unreachable() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: multipart/mixed; boundary="===============6658091666264601766==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============6658091666264601766== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="YeTVM2jZrgn6HX5o" Content-Disposition: inline --YeTVM2jZrgn6HX5o Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jul 13, 2024 at 04:44:03PM +0200, epirat07@gmail.com wrote: > On 13 Jul 2024, at 2:47, Andreas Rheinhardt wrote: >=20 > > Marvin Scholz: > >> --- > >> libavutil/avassert.h | 12 ++++++++++++ > >> 1 file changed, 12 insertions(+) > >> > >> diff --git a/libavutil/avassert.h b/libavutil/avassert.h > >> index 1895fb7551..cdab912fe4 100644 > >> --- a/libavutil/avassert.h > >> +++ b/libavutil/avassert.h > >> @@ -75,4 +75,16 @@ > >> */ > >> void av_assert0_fpu(void); > >> > >> +/** > >> + * Assert this can not be reached > >> + */ > >> +#if AV_HAS_BUILTIN(__builtin_unreachable) > >> +#define av_assert_unreachable() do { \ > >> + av_assert2(0); \ > >> + __builtin_unreachable(); \ > >> +} while (0) > >> +#else > >> +#define av_assert_unreachable() av_assert2(0) > >> +#endif > >> + > >> #endif /* AVUTIL_AVASSERT_H */ > >> > >> base-commit: 85706f5136cf7c88f95843b2634dd3f7d7d2cb6d > > > > You are not the first one with this idea: > > https://ffmpeg.org/pipermail/ffmpeg-devel/2024-May/328116.html > > But Michael Niedermayer thinks that adding a new macro instead of > > directly reusing av_assert is more complicated. > > > Oh I did not notice that one, thanks=E2=80=A6 >=20 > I definitely think an av_assert_unreachable() is clearer than > av_assert0(!"reached") too, obviously, else I would not propose it. >=20 > (Somewhat proven by these two cases fixed by the patch where we use > av_assert1/2(0) variants which then result in the compiler not knowing > these are unreachable cases when the assert is not enabled.) >=20 > If this approach is rejected, I can submit a version that uses > av_assert0(!"reached=E2=80=9C). I think you look at this from the wrong side We have 3 levels of assert() and we have one threshold to decide how much we want to check at runtime what we do NOT have is a threshold at what we want the compiler to assume teh statment is true And here this av_assert1(0) is not assumed true and not checked at runtime so the compiler thinks this is reachable I think the solution is to add this 2nd threshold so we can gloablly use av_assert*() for optimization This should remove the warning with no changes to the code thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The greatest way to live with honor in this world is to be what we pretend to be. -- Socrates --YeTVM2jZrgn6HX5o Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZpO7fwAKCRBhHseHBAsP q9CNAJ9QWCiLPQ0b99eD7lUvYb8fppoZTQCfeIkvmp6bbwa947UJp669mf4NXfw= =kp7Y -----END PGP SIGNATURE----- --YeTVM2jZrgn6HX5o-- --===============6658091666264601766== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --===============6658091666264601766==--