From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 593643857831; Tue, 6 Feb 2024 21:32:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 593643857831 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707255179; bh=pEu3srqSHuqhGXZ+87tAuXfT9qMTy5JsU0GalXgSVL4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qcCS41SEe3HSzh3O8HtnhiTjwQhZFdGrGkieIMoIDZNVGZb+WO0TR4kETltLlgsMR brM/zoitadqqYvJ50OZ1o7r0jvKIQZSWz/2Ax/fv3n4x2RVuWEwgiFxn3ZUl+Fl4Va yW2MWhHzNjGCKle1nA9c0M9cVsenmGHYyHnTT6rU= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/87744] Some valid instantiations of linear_congruential_engine produce compiler errors when __int128 isn't available Date: Tue, 06 Feb 2024 21:32:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 7.3.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW 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: 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=3D87744 --- Comment #4 from Jakub Jelinek --- (In reply to Jonathan Wakely from comment #1) > Created attachment 57345 [details] > Use 64-bit integers to do 128-bit arithmetic >=20 > This patch defines a custom type that implements the necessary 128-bit > arithmetic for linear_congruential_engine without __int128. >=20 > It's an order of magnitude slower than using __int128 natively on x86_64, > but it gives the right results. if (__builtin_uaddll_overflow(__l._M_lo, __c, &__l._M_lo)) __l._M_hi++; Why not just __l._M_hi +=3D __builtin_uaddll_overflow(__l._M_lo, __c, &__l._= M_lo); and similarly for subtraction? Is the reason for using the clang compat builtins instead of __builtin_{add,sub,mul}_overflow the compatibility with clang versions which don't support these?=