From patchwork Wed Mar 1 12:08:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 734181 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vYDkw1b8Kz9s7k for ; Wed, 1 Mar 2017 23:09:11 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="AcVku/BQ"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=CX0Wtk9GLmDNU11zf+Ghu7i/95mVqrHOzDOcVe7TOsrdsy40Zr lH/i304h14etWade6Fu6vfMc9F4RP37n9t2UtD7JoCUgTiXQlJX+xhKDy+9eolhh H8UvRA1TRmYGvnibMC8D+7GpKF0bCPUJyIJRyAWkz89zbu0rOpn7sgHJU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=1ES2SiRkCwuATw8gBqLnoZj+4u4=; b=AcVku/BQZqFGuLlrOZ82 qwZfPdjCvITz5jFG+KuvypqB4PdosTxf1pwyLCoa9tDT63EHQDsoCqxD157Fn/SE /3dQL+L2Oia6Tk75G+4UHtEY/edmFtFCs8F6bKbhwUX6EwMI7W+kvN/zYKFh/zNW 7t0rzIipZDaGYeb7zBlSglI= Received: (qmail 4159 invoked by alias); 1 Mar 2017 12:09:01 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 4145 invoked by uid 89); 1 Mar 2017 12:09:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1652 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 01 Mar 2017 12:09:00 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 46488ABA2; Wed, 1 Mar 2017 12:08:58 +0000 (UTC) Date: Wed, 1 Mar 2017 13:08:58 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: richard.sandiford@arm.com Subject: [PATCH] Add wide_int_storage::operator= Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 In debugging a -Wuninitialized issue from ipa-cp.c which does vr.min = vr.max = wi::zero (INT_TYPE_SIZE); I figured we are missing this operator and are thus copying possibly uninitialized data. This means instead of a plain assignment of wide_int_storage we get a loop here. So I'm not 100% sure this "omission" wasn't on purpose. Note there already is a copy constructor implemented in terms of wi::copy. Bootstrap / regtest running on x86_64-unknown-linux-gnu. Ok? Thanks, Richard. 2017-03-01 Richard Biener * wide-int.h (wide_int_storage::operator=): Implement in terms of wi::copy. Index: gcc/wide-int.h =================================================================== --- gcc/wide-int.h (revision 245803) +++ gcc/wide-int.h (working copy) @@ -1019,6 +1019,9 @@ public: HOST_WIDE_INT *write_val (); void set_len (unsigned int, bool = false); + template + wide_int_storage &operator = (const T &); + static wide_int from (const wide_int_ref &, unsigned int, signop); static wide_int from_array (const HOST_WIDE_INT *, unsigned int, unsigned int, bool = true); @@ -1058,6 +1061,18 @@ inline wide_int_storage::wide_int_storag wi::copy (*this, xi); } +template +inline wide_int_storage& +wide_int_storage::operator = (const T &x) +{ + { STATIC_ASSERT (!wi::int_traits::host_dependent_precision); } + { STATIC_ASSERT (wi::int_traits::precision_type != wi::CONST_PRECISION); } + WIDE_INT_REF_FOR (T) xi (x); + precision = xi.precision; + wi::copy (*this, xi); + return *this; +} + inline unsigned int wide_int_storage::get_precision () const {