From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78413 invoked by alias); 20 Jun 2017 20:52:46 -0000 Mailing-List: contact jit-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: jit-owner@gcc.gnu.org Received: (qmail 78344 invoked by uid 89); 20 Jun 2017 20:52:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Jun 2017 20:52:44 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE40F80C19; Tue, 20 Jun 2017 20:52:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DE40F80C19 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dmalcolm@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DE40F80C19 Received: from c64.redhat.com (ovpn-112-19.phx2.redhat.com [10.3.112.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7A526E73C; Tue, 20 Jun 2017 20:52:41 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org, jit@gcc.gnu.org Cc: msebor@redhat.com, David Malcolm Subject: [committed] Fix -Werror=class-memaccess failures in jit testsuite (PR jit/81144) Date: Sun, 01 Jan 2017 00:00:00 -0000 Message-Id: <1497993952-49602-1-git-send-email-dmalcolm@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 20 Jun 2017 20:52:43 +0000 (UTC) X-IsSubscribed: yes X-SW-Source: 2017-q2/txt/msg00002.txt.bz2 This patch fixes a couple of failures of the form: error: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'struct quadratic_test'; use assignment or value-initialization instead [-Werror=class-memaccess] note: 'struct quadratic_test' declared here cc1plus: all warnings being treated as errors seen within the jit testsuite, by using zero-initialization instead of memset. (presumably introduced by r249234 aka a324786b4ded9047d05463b4bce9d238b6c6b3ef) Successfully tested on x86_64-pc-linux-gnu; takes jit.sum from: # of expected passes 9211 # of unexpected failures 2 to: # of expected passes 9349 Martin: it's unclear to me what the benefit of the warning is for these cases. AIUI, it's complaining because the code is calling the default ctor for struct quadratic_test, and then that object is being clobbered by the memset. But if I'm reading things right, the default ctor for this struct zero-initializes all fields. Can't the compiler simply optimize away the redundant memset, and not issue a warning? gcc/testsuite/ChangeLog: PR jit/81144 * jit.dg/test-operator-overloading.cc (make_test_quadratic): Replace memset call with zero-initialization. * jit.dg/test-quadratic.cc (make_test_quadratic): Likewise. --- gcc/testsuite/jit.dg/test-operator-overloading.cc | 3 +-- gcc/testsuite/jit.dg/test-quadratic.cc | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/jit.dg/test-operator-overloading.cc b/gcc/testsuite/jit.dg/test-operator-overloading.cc index cbb1e98..f57b3fc 100644 --- a/gcc/testsuite/jit.dg/test-operator-overloading.cc +++ b/gcc/testsuite/jit.dg/test-operator-overloading.cc @@ -272,8 +272,7 @@ make_test_quadratic (quadratic_test &testcase) void create_code (gcc_jit_context *ctxt, void *user_data) { - struct quadratic_test testcase; - memset (&testcase, 0, sizeof (testcase)); + struct quadratic_test testcase = {}; testcase.ctxt = ctxt; make_types (testcase); make_sqrt (testcase); diff --git a/gcc/testsuite/jit.dg/test-quadratic.cc b/gcc/testsuite/jit.dg/test-quadratic.cc index f347669..61b5cdd 100644 --- a/gcc/testsuite/jit.dg/test-quadratic.cc +++ b/gcc/testsuite/jit.dg/test-quadratic.cc @@ -328,8 +328,7 @@ make_test_quadratic (quadratic_test &testcase) void create_code (gcc_jit_context *ctxt, void *user_data) { - struct quadratic_test testcase; - memset (&testcase, 0, sizeof (testcase)); + struct quadratic_test testcase = {}; testcase.ctxt = ctxt; make_types (testcase); make_sqrt (testcase); -- 1.8.5.3