From patchwork Fri Sep 7 09:12:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 967285 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-485323-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="tiavgwZN"; dkim-atps=neutral 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 426BXw2jZKz9s4s for ; Fri, 7 Sep 2018 19:12:30 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=YWVpoRf+ofqHYgyZjUScek1nNBPBEuMpd4Up9kG+qtNALylbp6 xmIE7PVpYOqWG0jzF1RPgOIWT+bdeO+hcFwwH5AKAdRH7pOIspFtt9U0VOJWD521 0n4+AhrteFTjWqM8sG02Qpx4Lc0Qzf+FY4YMP+oah8vXJ80LARqjQNC7E= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=2kVxKm98qfyfYZioNM9L1npCPaU=; b=tiavgwZNBwL1atLhOZ1B 5C25mtYHG7kCPHCJD3KVhT21JVmg7XKg83qPTAaF5qZd/LANjg4oxyvfFTOwf8H7 B+AI+HLDRyNBb1LbkKQ1/P5SCsqu3G+bZlKYLGKDMXbOpoJ1O2ePWnT0XzFvIbVO X4xqrjg/JddqfHLDMeeczXI= Received: (qmail 47904 invoked by alias); 7 Sep 2018 09:12:22 -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 47892 invoked by uid 89); 7 Sep 2018 09:12:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=semi, sk:gimple, sk:gimple-, sk:alloca_ X-HELO: mail-wm0-f41.google.com Received: from mail-wm0-f41.google.com (HELO mail-wm0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Sep 2018 09:12:20 +0000 Received: by mail-wm0-f41.google.com with SMTP id o18-v6so13946315wmc.0 for ; Fri, 07 Sep 2018 02:12:19 -0700 (PDT) Received: from abulafia.quesejoda.com (247.red-79-147-188.dynamicip.rima-tde.net. [79.147.188.247]) by smtp.gmail.com with ESMTPSA id j20-v6sm5150788wmh.9.2018.09.07.02.12.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 02:12:17 -0700 (PDT) To: gcc-patches Cc: Andrew MacLeod From: Aldy Hernandez Subject: avoid uninitialized use in -Walloca* pass Message-ID: Date: Fri, 7 Sep 2018 05:12:15 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 X-IsSubscribed: yes Semi obvious patch here... As the comment for alloca_type_and_limit says: // For ALLOCA_BOUND_MAYBE_LARGE and ALLOCA_BOUND_DEFINITELY_LARGE // types, this field indicates the assumed limit if known or // integer_zero_node if unknown. For any other alloca types, this // field is undefined. So, there's no sense in creating ALLOCA_BOUND_*_LARGE entries without a limit, as doing so would trigger reading undefined memory later on. We could put an assert here, but I'd rather just let the constructor build the right thing. OK for trunk? gcc/ * gimple-ssa-warn-alloca.c (alloca_type_and_limit::alloca_type_and_limit): Initialize limit field for ALLOCA_BOUND_*_LARGE. diff --git a/gcc/gimple-ssa-warn-alloca.c b/gcc/gimple-ssa-warn-alloca.c index 4d5aed866e1..d1b1de4a2d5 100644 --- a/gcc/gimple-ssa-warn-alloca.c +++ b/gcc/gimple-ssa-warn-alloca.c @@ -128,7 +128,11 @@ struct alloca_type_and_limit { alloca_type_and_limit (); alloca_type_and_limit (enum alloca_type type, wide_int i) : type(type), limit(i) { } - alloca_type_and_limit (enum alloca_type type) : type(type) { } + alloca_type_and_limit (enum alloca_type type) : type(type) + { if (type == ALLOCA_BOUND_MAYBE_LARGE + || type == ALLOCA_BOUND_DEFINITELY_LARGE) + limit = wi::to_wide (integer_zero_node); + } }; /* Return the value of the argument N to -Walloca-larger-than= or