Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2225980/?format=api
{ "id": 2225980, "url": "http://patchwork.ozlabs.org/api/patches/2225980/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260421235038.3083-1-gerris.rs@gmail.com/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api", "name": "GNU Compiler Collection", "link_name": "gcc", "list_id": "gcc-patches.gcc.gnu.org", "list_email": "gcc-patches@gcc.gnu.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260421235038.3083-1-gerris.rs@gmail.com>", "list_archive_url": null, "date": "2026-04-21T23:50:38", "name": "[gccrs,COMMIT] Fix corrupted GIMPLE for CompoundAssignmentExpr in const context", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "ee2d6bfe7620d5cbc01e148c71f7320ccd9b2950", "submitter": { "id": 92092, "url": "http://patchwork.ozlabs.org/api/people/92092/?format=api", "name": null, "email": "gerris.rs@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260421235038.3083-1-gerris.rs@gmail.com/mbox/", "series": [ { "id": 500904, "url": "http://patchwork.ozlabs.org/api/series/500904/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500904", "date": "2026-04-21T23:50:38", "name": "[gccrs,COMMIT] Fix corrupted GIMPLE for CompoundAssignmentExpr in const context", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/500904/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2225980/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2225980/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=OiQn1zK1;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=OiQn1zK1", "sourceware.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com", "sourceware.org; spf=pass smtp.mailfrom=gmail.com", "server2.sourceware.org;\n arc=none smtp.remote-ip=74.125.82.47" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0fJT5lh6z1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 09:51:19 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 52C524BA9034\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 23:51:17 +0000 (GMT)", "from mail-dl1-f47.google.com (mail-dl1-f47.google.com\n [74.125.82.47])\n by sourceware.org (Postfix) with ESMTPS id 0C3A04BA9000\n for <gcc-patches@gcc.gnu.org>; Tue, 21 Apr 2026 23:50:42 +0000 (GMT)", "by mail-dl1-f47.google.com with SMTP id\n a92af1059eb24-12c565476d7so11219112c88.1\n for <gcc-patches@gcc.gnu.org>; Tue, 21 Apr 2026 16:50:41 -0700 (PDT)", "from\n runnervmeorf1.zjbz4sd1q3pebdclggu0nfifbe.dx.internal.cloudapp.net\n ([68.220.58.1]) by smtp.gmail.com with ESMTPSA id\n a92af1059eb24-12c831d5b29sm20495721c88.8.2026.04.21.16.50.39\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 21 Apr 2026 16:50:40 -0700 (PDT)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 52C524BA9034", "OpenDKIM Filter v2.11.0 sourceware.org 0C3A04BA9000" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 0C3A04BA9000", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 0C3A04BA9000", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776815442; cv=none;\n b=i8fDGnYQbvrHwfLEPUHLo5/KbAJS2iQyVWTK+yyD1E3hW56UWfSFnIJx1Vt958+XSv0Ac3DpUcE+ajadfbkz7XGaIFy0+WJTI7rZzlBqr/MfvpB6GsBZSnBVmsohy/D8WJNAJWAJuEVBszm/xEriDmSL589+izdXYifC1MPTPNw=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776815442; c=relaxed/simple;\n bh=fqDnakrVIObwVU1uEPgyhGxBayRwzbUUif9UINM0qdY=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=v7MRWJ+C9aIfMJX11wOpGdiLemmoL4sYgXJ+nr/agq2A/eFfV1jQlUQE5Vu+8AlWHIHExrEQIjNhXTlJt0+Ufsk1g7iPzk5RQB/O5f6adDb3izrQk2j12o5lPjecUPKAfVf8i2sgAdOe1uodS9d0yBDlKQOkTwvdhO0y3SvyMLs=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1776815441; x=1777420241; darn=gcc.gnu.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=rWkyOwDQf6GjvM8lPhtLFrRFjslc3Eb7LBBKbbzdb88=;\n b=OiQn1zK14OJ1pIl30JHLwnEhj/cIGLCcqVVBz+g/3wRX0wgSCCV71s4vFUeNomQBHb\n ugqmgJOqYE4EP65QJRoVAD24YJZ0EXEcAuui28t4N9ZK/x97zjb/zC9rGs5divXziVCK\n A0NqDR/iNQFE0zDmZ1zSX4QAS8akE5QfU5oABKiDlrTTbmf2Iw1mZQvEw2gaIMeGUnZe\n bf7akM7IZ5CAl0GrDyV4p6kslVfljY6o3VTa1f51U4vhcwp31C461gA0o4iPjfH3omdN\n qqhYZBuDLsi8pBFDjy7E2Khzgm8MXKodickgIEvQs84F9kiH9pKjfxCdnCOPEdON1wwj\n uQzw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776815441; x=1777420241;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=rWkyOwDQf6GjvM8lPhtLFrRFjslc3Eb7LBBKbbzdb88=;\n b=eR0lcalV+ke841WMM3gttOQGaYAvTPrpiP5KedH+Sm0WZTYfZY/gLtF8XEDLP2ZtLG\n 43qHtETEdeB2Binb2owfwrSYou/yO6F1D9U06hv2bFFuWa3eItt0EkuxS+zFF2ei9WA/\n 7veHGpIM4z77raC3EvfjH153IzVwXR3oYOYuPaTSc1+7F820egDBkjmeLKygrwkQ3Kf3\n gcelPCP73sZC7A+wfJKRv3YBtfDEhiaTEPHPzcWskshxMiTl1WLOQ8eqwl8JP7AD1b/m\n +uRI8nr9PCobZPEhF/3Wk3ZPpYognMs6vWcOlFPfOFsxCq123zBogZm1vi6AwvEy0QOf\n FdTQ==", "X-Gm-Message-State": "AOJu0YxJxUwd+MqPDokkgj37v1Kw4m9w0ngmx9J2rGA5ASaLIRU04KZ0\n A5/7hiJUGsfZMvytxhR40SRMoXvF+u+vFgf8ytuEbr4lJqy2UxXvk7C98L1CCw==", "X-Gm-Gg": "AeBDietId04jFA78rP19dU28lgc6pmsAq9EP/vfldYxo4kjUgvcKkOBm62Db2LrIw3p\n +eY2xz9CMfsQ6c2OSIRgguRLMSMZDzQxIYk7AUw0GknkwpktguxMIBR8B5Kh0NGpKqyLBtCv8kL\n VupBcLHDnmpsdXyVkz40sA+r4XrPNcZl7uJvpxtY5zdVoKNYNm2prdE5mzAsJtF+tOaUXmas1RE\n sZ0Sb7/T/nBv1gnWtJPnkdqet86R4migpXoqAe//tSu7PP9ZVGlTWGjGDvEa712bseyAMwriCJ1\n UFi4SR7dVpmCHQhuv9uRHEGTiMlhMBeotG6f2MFyDaXSgzCKUSokGIVFCoF48OpnOBt77dOagYX\n 8GFGY+NzHla+tEnrT+DNwmzQb7i4HPovi34x0OvAwYk5CuTWB+N39V8uHZcqqkswmn9KoxpaJ2A\n +VAljw+9Cy1IdkEP7WgLWZVrzRro0yERckO/Jb78DlystvwT47ETqiyAL4uXIhhT+bXHnSnskQ4\n UWLskdpG2eBQ7puqO3R1E12a1AKng==", "X-Received": "by 2002:a05:7022:6289:b0:12a:9b80:8a1b with SMTP id\n a92af1059eb24-12c73fb27fcmr11359515c88.34.1776815440591;\n Tue, 21 Apr 2026 16:50:40 -0700 (PDT)", "From": "gerris.rs@gmail.com", "To": "gcc-patches@gcc.gnu.org,\n\tgcc-rust@gcc.gnu.org", "Cc": "pierre-emmanuel.patry@embecosm.com, arthur.cohen@embecosm.com,\n dkm+gccrs@kataplop.net, Islam-Imad <islamimad404@gmail.com>", "Subject": "[gccrs COMMIT] Fix corrupted GIMPLE for CompoundAssignmentExpr in\n const context", "Date": "Tue, 21 Apr 2026 23:50:38 +0000", "Message-ID": "<20260421235038.3083-1-gerris.rs@gmail.com>", "X-Mailer": "git-send-email 2.43.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "gcc-patches@gcc.gnu.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>", "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>", "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "From: Islam-Imad <islamimad404@gmail.com>\n\nCompoundAssignmentExpr codegen was missing the final assignment statement\nwhen it was evaluated in a const context.\n\ngcc/rust/ChangeLog:\n\n\t* backend/rust-compile-expr.cc (CompileExpr::visit): Emit the\n\tmissing assignment for CompoundAssignmentExpr.\n\ngcc/testsuite/ChangeLog:\n\n\t* rust/compile/const-compound-assignment.rs: New test.\n\t* rust/execute/const-compound-assignment.rs: New test.\n\nSigned-off-by: Islam-Imad <islamimad404@gmail.com>\n---\nThis change was merged into the gccrs repository and is posted here for\nupstream visibility and potential drive-by review, as requested by GCC\nrelease managers.\nEach commit email contains a link to its details on github from where you can\nfind the Pull-Request and associated discussions.\n\n\nCommit on github: https://github.com/Rust-GCC/gccrs/commit/679aad3804e8443ec5181fd184785d82aec42bdf\n\nThe commit has been mentioned in the following pull-request(s):\n - https://github.com/Rust-GCC/gccrs/pull/4520\n\n gcc/rust/backend/rust-compile-expr.cc | 27 +++++++-------\n .../rust/compile/const-compound-assignment.rs | 15 ++++++++\n .../rust/execute/const-compound-assignment.rs | 35 +++++++++++++++++++\n 3 files changed, 63 insertions(+), 14 deletions(-)\n create mode 100644 gcc/testsuite/rust/compile/const-compound-assignment.rs\n create mode 100644 gcc/testsuite/rust/execute/const-compound-assignment.rs\n\n\nbase-commit: 3432069729f6868c92de792e09d0c803dcc1618e", "diff": "diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc\nindex 55b3534a1..6b21a7745 100644\n--- a/gcc/rust/backend/rust-compile-expr.cc\n+++ b/gcc/rust/backend/rust-compile-expr.cc\n@@ -192,9 +192,9 @@ void\n CompileExpr::visit (HIR::CompoundAssignmentExpr &expr)\n {\n auto op = expr.get_expr_type ();\n- auto lhs = CompileExpr::Compile (expr.get_lhs (), ctx);\n- auto rhs = CompileExpr::Compile (expr.get_rhs (), ctx);\n-\n+ tree lhs = CompileExpr::Compile (expr.get_lhs (), ctx);\n+ tree rhs = CompileExpr::Compile (expr.get_rhs (), ctx);\n+ tree compound_assignment = NULL_TREE;\n // this might be an operator overload situation lets check\n TyTy::FnType *fntype;\n bool is_op_overload = ctx->get_tyctx ()->lookup_operator_overload (\n@@ -203,38 +203,37 @@ CompileExpr::visit (HIR::CompoundAssignmentExpr &expr)\n {\n auto lang_item_type = LangItem::CompoundAssignmentOperatorToLangItem (\n \texpr.get_expr_type ());\n- auto compound_assignment\n+ compound_assignment\n \t= resolve_operator_overload (lang_item_type, expr, lhs, rhs,\n \t\t\t\t expr.get_lhs (), expr.get_rhs ());\n- ctx->add_statement (compound_assignment);\n-\n- return;\n }\n-\n- if (ctx->in_fn () && !ctx->const_context_p ())\n+ else if (ctx->in_fn () && !ctx->const_context_p ())\n {\n- auto tmp = NULL_TREE;\n+ tree tmp = NULL_TREE;\n Bvariable *receiver\n \t= Backend::temporary_variable (ctx->peek_fn ().fndecl, NULL_TREE,\n \t\t\t\t TREE_TYPE (lhs), lhs, true,\n \t\t\t\t expr.get_locus (), &tmp);\n- auto check\n+ tree check\n \t= Backend::arithmetic_or_logical_expression_checked (op, lhs, rhs,\n \t\t\t\t\t\t\t expr.get_locus (),\n \t\t\t\t\t\t\t receiver);\n ctx->add_statement (check);\n-\n- translated\n+ compound_assignment\n \t= Backend::assignment_statement (lhs,\n \t\t\t\t\t receiver->get_tree (expr.get_locus ()),\n \t\t\t\t\t expr.get_locus ());\n }\n else\n {\n- translated\n+ tree expr_tree\n \t= Backend::arithmetic_or_logical_expression (op, lhs, rhs,\n \t\t\t\t\t\t expr.get_locus ());\n+ compound_assignment\n+\t= Backend::assignment_statement (lhs, expr_tree, expr.get_locus ());\n }\n+ ctx->add_statement (compound_assignment);\n+ translated = unit_expression (expr.get_locus ());\n }\n \n void\ndiff --git a/gcc/testsuite/rust/compile/const-compound-assignment.rs b/gcc/testsuite/rust/compile/const-compound-assignment.rs\nnew file mode 100644\nindex 000000000..3ec68ba44\n--- /dev/null\n+++ b/gcc/testsuite/rust/compile/const-compound-assignment.rs\n@@ -0,0 +1,15 @@\n+// { dg-options \"-w -O0 -fdump-tree-gimple\" }\n+#![feature(no_core)]\n+#![no_core]\n+\n+const fn test(mut x: i32) -> i32 {\n+ x += 5;\n+ x\n+}\n+\n+const X: i32 = test(10);\n+\n+fn main() {\n+ // { dg-final { scan-tree-dump-times {x = 15} 1 gimple } }\n+ let x = X;\n+}\n\\ No newline at end of file\ndiff --git a/gcc/testsuite/rust/execute/const-compound-assignment.rs b/gcc/testsuite/rust/execute/const-compound-assignment.rs\nnew file mode 100644\nindex 000000000..ce5ddde8e\n--- /dev/null\n+++ b/gcc/testsuite/rust/execute/const-compound-assignment.rs\n@@ -0,0 +1,35 @@\n+// { dg-output \"45\\r*\\n55\\r*\\n\" }\n+#![feature(no_core)]\n+#![no_core]\n+\n+extern \"C\" {\n+ fn printf(s: *const i8, ...);\n+}\n+\n+fn dump_number(num: i32) {\n+ unsafe {\n+ let a = \"%i\\n\\0\";\n+ let c = a as *const str as *const i8;\n+ printf(c, num);\n+ }\n+}\n+\n+const fn play(b: i32) -> i32 {\n+ let mut res = 0;\n+ let mut i = 0;\n+ while i < b {\n+ res += i;\n+ i += 1;\n+ }\n+ res\n+}\n+\n+fn main() -> i32 {\n+ const A: i32 = play(10);\n+ dump_number(A);\n+\n+ let b: i32 = play(11);\n+ dump_number(b);\n+\n+ 0\n+}\n", "prefixes": [ "gccrs", "COMMIT" ] }