From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41221 invoked by alias); 19 May 2017 20:07:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 41198 invoked by uid 89); 19 May 2017 20:07:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy= X-HELO: mail-qk0-f181.google.com Received: from mail-qk0-f181.google.com (HELO mail-qk0-f181.google.com) (209.85.220.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 19 May 2017 20:07:16 +0000 Received: by mail-qk0-f181.google.com with SMTP id y201so69933202qka.0 for ; Fri, 19 May 2017 13:07:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=5ov3ZPmlVoeeHhnjCswUmZsrGkd85tZ+UgpF5RCXiYQ=; b=ny24OvTwuPYEcF4zc5ix3eL6EENDsWqht1h4MoPx0+26l29RCjsFegSIkUWLdbH0CA 66mo1Z0wfEFsLHv5vx0AzabeigLFbiyfF9o8dCeIMMvZbuAJQ3mUNmtVUq37BnIgyIgw fbX4oDlcOHxVZDTy6RC2lARW/GKkmL1FTcFjlkFZ50/L5IcokXg0Iv0LZ5ky8u+BoC/u 5Uh1pNC/wv7y5rbfN0EJWBh40wMBCT3gw+3+AHRgOFHmH8AQSMQigGFMtbfNvnK5lDSC dq1RbbdtStlpTkuX6f/sP4PaEKAgJ+PleRvlVTiI4Jg82rgmrKLnxsCUnRn3Qtv8kcS7 /EPQ== X-Gm-Message-State: AODbwcCkvRZ+Xd9hjhLa0oJM/FTvqufuoNH4I4ls6OyBjbQpifnTPo6T tOPr81mlWNcNNg== X-Received: by 10.55.212.134 with SMTP id s6mr4531245qks.128.1495224437718; Fri, 19 May 2017 13:07:17 -0700 (PDT) Received: from localhost.localdomain (184-96-147-140.hlrn.qwest.net. [184.96.147.140]) by smtp.gmail.com with ESMTPSA id f94sm6427666qtb.16.2017.05.19.13.07.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 May 2017 13:07:17 -0700 (PDT) Subject: Re: [PATCH] warn on mem calls modifying objects of non-trivial types (PR 80560) To: Jason Merrill References: <656ca1db-1082-b1ed-a911-ba7bf48f09c0@redhat.com> Cc: Pedro Alves , Gcc Patch List From: Martin Sebor Message-ID: Date: Fri, 19 May 2017 21:11:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg01615.txt.bz2 On 05/19/2017 01:07 PM, Jason Merrill wrote: > On Tue, May 16, 2017 at 5:39 PM, Martin Sebor wrote: >> On 05/16/2017 01:41 PM, Jason Merrill wrote: >> >>> I'm still not convinced we need to consider standard-layout at all. >> >> I agree. The patch doesn't make use of is_standard_layout_p(). >> It defines its own helper called almost_std_layout_p() that >> combines trivial_type_p() with tests for non-public members, > > That's the part that seems unnecessary. Why do we care about > non-public members? Because modifying them breaks encapsulation. If I take a legacy struct, make some of its members private, and define accessors and modifiers to manipulate those members and maintain invariants between them, I will want to check and adjust all code that changes objects of the struct in ways that might violate the invariants. What common use case are you concerned about that isn't more appropriately expressed using the generated default or copy constructor or assignment operator? Martin