From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CDD833858C52; Fri, 23 Sep 2022 08:59:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CDD833858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663923568; bh=6MtOoZRrYmnmGD96vGi40nuhGl7gyGwgcjU6Kp4hWl8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eIrAe9RwmARXS1vSSXK6DjNGVVIB1o6SD0YVRONm5EGt4tB5OaogXC0rxt/8veGYM 3IQwgmuS2n+1xXsm1Z+pT+9MBm0xuN+9URk+qJ20TFuwUjxioD9XOzs4fsbBHGEqkZ JmRU/VWm76+S22WD/1TTOqzgGO6hM6aB2ZF+ZleU= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/106981] [10/11/12/13 Regression][OpenACC][OpenMP] ICE in decompose, at wide-int.h:984 with '#pragma omp/acc atomic capture' Date: Fri, 23 Sep 2022 08:59:27 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: ice-on-invalid-code, openacc, openmp X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org 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: 10.5 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=3D106981 --- Comment #5 from Jakub Jelinek --- Slightly more reduced: void foo (int a, double *b, double *c, double *d, long long e) { #pragma omp atomic capture c[a] =3D d[((int) (e / 10 + 1))] =3D b[a] + d[((int) e / 10 + 1)]; } The fix could be either partially backport what C++ FE did in --- gcc/c/c-typeck.cc.jj 2022-09-23 09:02:56.525318361 +0200 +++ gcc/c/c-typeck.cc 2022-09-23 10:33:06.596467788 +0200 @@ -16069,6 +16069,9 @@ c_tree_equal (tree t1, tree t2) if (code1 !=3D code2) return false; + if (CONSTANT_CLASS_P (t1) && !comptypes (TREE_TYPE (t1), TREE_TYPE (t2))) + return false; + switch (code1) { case INTEGER_CST: Or we could --- gcc/c/c-typeck.cc.jj 2022-09-23 09:02:56.525318361 +0200 +++ gcc/c/c-typeck.cc 2022-09-23 10:33:06.596467788 +0200 @@ -16072,7 +16070,7 @@ c_tree_equal (tree t1, tree t2) switch (code1) { case INTEGER_CST: - return wi::to_wide (t1) =3D=3D wi::to_wide (t2); + return wi::to_widest (t1) =3D=3D wi::to_widest (t2); case REAL_CST: return real_equal (&TREE_REAL_CST (t1), &TREE_REAL_CST (t2)); but then it is accepted instead of rejected unlike C++. I'm afraid even the for (code1 =3D TREE_CODE (t1); CONVERT_EXPR_CODE_P (code1) || code1 =3D=3D NON_LVALUE_EXPR; code1 =3D TREE_CODE (t1)) t1 =3D TREE_OPERAND (t1, 0); for (code2 =3D TREE_CODE (t2); CONVERT_EXPR_CODE_P (code2) || code2 =3D=3D NON_LVALUE_EXPR; code2 =3D TREE_CODE (t2)) t2 =3D TREE_OPERAND (t2, 0); stuff is dangerous, I guess one could construct a valid OpenMP testcase lik= e: void bar (int *a) { unsigned int b =3D 0x100; #pragma omp atomic update a[(unsigned char) b] =3D a[(unsigned short) b] + a[(unsigned char) b]; #pragma omp atomic update a[(unsigned char) b] =3D a[(unsigned char) b] + a[(unsigned short) b]; } where for C++ I think we do the right thing in both cases, atomic increment= of a[0] by a[0x100], but in C we do atomic increment of a[0] by a[0] in the fi= rst case. Now, wonder what will break if I just strip same type casts and for others like in C++ require same type.=