From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D07863858C55; Wed, 21 Sep 2022 13:20:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D07863858C55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663766425; bh=NbIN3z+txQ6rFVhTeeA3kFbr1wMGfPVHW1iFlcwgLyw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jU1uhrbpXczdl2RRSNAlNBxqmqDMmqYjr6t8/dh03bBRO0FeY9H1iTyw010TcHJFv H8vqt+//CMDx0mgrR/OgBjQUtHAJXtOnoG+ZbyK5SA3+5USQ5Uz/CzXhotO4A/JD+F xnJMSknfY2W8AtrjGVN11CFwRWj1D/NUXxkfpOrQ= From: "burnus 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: Wed, 21 Sep 2022 13:20:24 +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: burnus 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: keywords 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 Tobias Burnus changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|ice-on-valid-code |ice-on-invalid-code --- Comment #2 from Tobias Burnus --- Fails in c_parser_binary_expression's POP for the second c_type_equal, which is probably: stack[sp].expr = \ =3D convert_lvalue_to_rvalue (stack[sp].loc, = \ stack[sp].expr, true, true); = \ there: c_tree_equal (t1=3D0x7ffff710dce0, t2=3D0x7ffff710dba0) at ../../repos/gcc-trunk-commit/gcc/c/c-typeck.cc:16039 (gdb) p debug((tree)0x7ffff710dce0) *(totals + (sizetype) ((long unsigned int) (x % ((int) n / 10 + 1)) * 8)) (gdb) p debug((tree)0x7ffff710dba0) *(totals + (sizetype) ((long unsigned int) (x % (int) ((unsigned int) (n / = 10) + 1)) * 8)) where 'n' is 'long long' and 'x' and the digits are 'int' - the expr right = of '%' differs in terms of casts. The ICE can be prevented with: ------------------------ --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -16216,6 +16216,9 @@ c_tree_equal (tree t1, tree t2) && n !=3D TREE_OPERAND_LENGTH (t2)) return false; + if (n >=3D TREE_OPERAND_LENGTH (t2)) + return false; + for (i =3D 0; i < n; ++i) if (!c_tree_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i))) return false; ------------------------ With this patch, the code fails =E2=80=93 but C++ and C have different mess= ages. * gcc =E2=80=93 points to tailing ';': input5.i:7:86: error: invalid form of =E2=80=98#pragma omp atomic=E2=80=99 = before =E2=80=98;=E2=80=99 token 7 | c[x] =3D totals[x%((int)(n/10 + 1))] =3D (a[x] + b[x]) + totals[x%((int) n/10 + 1)]; |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ^ * g++ - points to '(' in '... =3D (a[x ...': input5.i:7:44: error: invalid form of =E2=80=98#pragma omp atomic=E2=80=99 = before =E2=80=98(=E2=80=99 token 7 | c[x] =3D totals[x%((int)(n/10 + 1))] =3D (a[x] + b[x]) + totals[x%((int) n/10 + 1)]; | ^ ************** Open... specification view. The expression is in the source code: __v_ =3D __x________________________ =3D ____expr_____ + ________x'________________ c[x] =3D totals[x%((int)(n/10 + 1))] =3D (a[x] + b[x]) + totals[x%((int) n= /10 + 1)]; and, obviously, x !=3D x' due to the cast differences. Looking at the OpenACC 3.2 spec, he last expr fits, except that x !=3D x': --------- If the atomic-clause is capture: v =3D x++; v =3D x--; v =3D ++x; v =3D --x; v =3D x binop=3D expr; v =3D x =3D x binop expr; v =3D x =3D expr binop x; --------- Likewise in OpenMP 5.2: --------- An update-atomic structured block is update-expr-stmt, an update expression statement that has one of the following forms: ... x =3D x binop expr; x =3D expr binop x; ... A capture-atomic structured block is capture-stmt, a capture statement that has one of the following forms: v =3D expr-stmt ... ---------=