From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 810F03858D1E for ; Tue, 2 May 2023 15:19:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 810F03858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683040758; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=AMi3/AtoG2HQc2NWMZ2qle3HdHf14pgjWzTAuq6QicM=; b=dQ2cNIaEbDNhcno4HTEf5ef6P1lkxWqzXQQNChCXFIo5Q0q4wfNydCnv//xS7uPyKG/N3d iJ7EnXm9QH3FBr4ILpj6/6CQ6Oqc7KaPQ2eh3DxlQLVPMssbz1wfyOZUo+fhKrsnI/0DUy HsmvNTSInKXsPU/prkr521m1RBLudS0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-501-Y7IS0Ru9NUKL2qqS96SUtw-1; Tue, 02 May 2023 11:19:14 -0400 X-MC-Unique: Y7IS0Ru9NUKL2qqS96SUtw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A806685A588 for ; Tue, 2 May 2023 15:19:14 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.156]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 63B26C15BAD; Tue, 2 May 2023 15:19:14 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 342FJCkM3172038 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 2 May 2023 17:19:12 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 342FJBAR3172037; Tue, 2 May 2023 17:19:11 +0200 Date: Tue, 2 May 2023 17:19:11 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, Patrick Palka Subject: [PATCH] c++: Fix up VEC_INIT_EXPR gimplification after r12-7069 Message-ID: Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi! During patch backporting, I've noticed that while most cp_walk_tree calls with cp_fold_r callback callers were changed from &pset to cp_fold_data &data, the VEC_INIT_EXPR gimplifications has not, so it still passes just address of a hash_set and so if during the folding we ever touch data->flags, we use uninitialized data there. The following patch changes it to do the same thing as cp_fold_function because the VEC_INIT_EXPR gimplifications will happen on function bodies only. Ok for trunk if it passes bootstrap/regtest? 2023-05-02 Jakub Jelinek * cp-gimplify.cc (cp_fold_data): Move definition earlier. (cp_gimplify_expr): Pass address of ff_genericize | ff_mce_false constructed data rather than &pset to cp_walk_tree with cp_fold_r. --- gcc/cp/cp-gimplify.cc.jj 2023-03-16 22:01:02.295090975 +0100 +++ gcc/cp/cp-gimplify.cc 2023-05-02 17:05:03.079652427 +0200 @@ -57,6 +57,13 @@ enum fold_flags { using fold_flags_t = int; +struct cp_fold_data +{ + hash_set pset; + fold_flags_t flags; + cp_fold_data (fold_flags_t flags): flags (flags) {} +}; + /* Forward declarations. */ static tree cp_genericize_r (tree *, int *, void *); @@ -505,8 +512,8 @@ cp_gimplify_expr (tree *expr_p, gimple_s *expr_p = expand_vec_init_expr (NULL_TREE, *expr_p, tf_warning_or_error); - hash_set pset; - cp_walk_tree (expr_p, cp_fold_r, &pset, NULL); + cp_fold_data data (ff_genericize | ff_mce_false); + cp_walk_tree (expr_p, cp_fold_r, &data, NULL); cp_genericize_tree (expr_p, false); copy_if_shared (expr_p); ret = GS_OK; @@ -1029,13 +1036,6 @@ struct cp_genericize_data in fold-const, we need to perform this before transformation to GIMPLE-form. */ -struct cp_fold_data -{ - hash_set pset; - fold_flags_t flags; - cp_fold_data (fold_flags_t flags): flags (flags) {} -}; - static tree cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data_) { Jakub