From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 90541 invoked by alias); 6 Jun 2017 16:11:01 -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 90501 invoked by uid 89); 6 Jun 2017 16:10:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f176.google.com Received: from mail-qt0-f176.google.com (HELO mail-qt0-f176.google.com) (209.85.216.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Jun 2017 16:10:58 +0000 Received: by mail-qt0-f176.google.com with SMTP id u12so112039527qth.0 for ; Tue, 06 Jun 2017 09:11:02 -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=rmw0pAZDA1ecofJ+HWLKMvTv3i8LN5Ax6D449hJIDkE=; b=Vu3FTuVaBvAYBvYRsiRT+q+URumIs/6xKjUAIklQsUd+oaCJID1cOJmfyQBVgtkshp nMXzEGjCxT/OBnCR5DsUdXEUrHw1i5TkBXNqoYPkkL6d7mVYD1hpPNVgBdbjgHtKSYj/ JkHT0aaWSj+MFbiwUTEaq7HNM+p1U9CRTpYLtQWHmJgOGhwDutaqI2uK8hSnnnbnT1YL A0p/eSqT3wnTi0DFkjRPEmc8YrPFaSr9EQaGSrb6SvB5YZrO6WLK2sYaNCSsB/U6TUEF 1/Y9r6VChAqsqGJjfS7FfKL+YivnJNnAimTCKIMeeOsLbKWIjtEb5AF/iaocCCqLLbPi oJ3w== X-Gm-Message-State: AODbwcDigLID5PsM6cHdIwZGAsZleGd1hkxdjh+VXwKZ2dAxjIr2UJTy Yk7GSmn8hwYEjNyR X-Received: by 10.237.62.136 with SMTP id n8mr34153660qtf.0.1496765460705; Tue, 06 Jun 2017 09:11:00 -0700 (PDT) Received: from localhost.localdomain (71-218-22-76.hlrn.qwest.net. [71.218.22.76]) by smtp.gmail.com with ESMTPSA id f124sm8481529qkj.57.2017.06.06.09.10.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 09:11:00 -0700 (PDT) Subject: Re: RFC: [PATCH] Add warn_if_not_aligned attribute To: "H.J. Lu" , Joseph Myers References: <20170604155212.GA8692@gmail.com> Cc: GCC Patches From: Martin Sebor Message-ID: Date: Tue, 06 Jun 2017 16: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-06/txt/msg00341.txt.bz2 On 06/06/2017 10:07 AM, Martin Sebor wrote: > On 06/05/2017 11:45 AM, H.J. Lu wrote: >> On Mon, Jun 5, 2017 at 8:11 AM, Joseph Myers >> wrote: >>> The new attribute needs documentation. Should the test be in >>> c-c++-common >> >> This feature does support C++. But C++ compiler issues a slightly >> different warning at a different location. >> >>> or does this feature not support C++? >>> >> >> Here is the updated patch with documentation and a C++ test. This >> patch caused a few testsuite failures: >> >> FAIL: gcc.dg/compat/struct-align-1 c_compat_x_tst.o compile >> >> /export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.dg/compat//struct-align-1.h:169:1: >> >> warning: alignment 1 of 'struct B2_m_inner_p_outer' is less than 16 >> >> FAIL: g++.dg/torture/pr80334.C -O0 (test for excess errors) >> >> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/torture/pr80334.C:4:8: >> >> warning: alignment 1 of 'B' is less than 16 >> > > Users often want the ability to control a warning, even when it > certainly indicates a bug. I would suggest to add an option to > make it possible for this warning as well. > > Btw., a bug related to some of those this warning is meant to > detect is assigning the address of an underaligned object to > a pointer of a natively aligned type. Clang has an option > to detect this problem: -Waddress-of-packed-member. It might > make a nice follow-on enhancement to add support for the same > thing. I mention this because I think it would make sense to > consider this when choosing the name of the GCC option (i.e., > rather than having two distinct but closely related warnings, > have one that detects both of these alignment type of bugs. A bug that has some additional context on this is pr 51628. A possible name for the new option suggested there is -Wpacked. Martin