From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93965 invoked by alias); 6 Jun 2017 16:59:32 -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 93955 invoked by uid 89); 6 Jun 2017 16:59:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 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-f173.google.com Received: from mail-qt0-f173.google.com (HELO mail-qt0-f173.google.com) (209.85.216.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Jun 2017 16:59:29 +0000 Received: by mail-qt0-f173.google.com with SMTP id w1so137068770qtg.2 for ; Tue, 06 Jun 2017 09:59:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=nK8VjtGPfUVVKp7tibwhngl1BKs7hfClj05Xojmp2W4=; b=qb4kjrWUvA1SQpY7mFvOulvBX23KYTq/8Cl+7lpb6LLwkOb7NHoiJhFzLsuHf1uK83 8Kie3t+kFvPPmc1UPctYAx1jAmtT6fYF9RU0CkodSrVam3CQdSYD4t/JKwTL1dGXtv1e FwAv4iduo05j/ue4iYbgkzaet94qxjNNuILlBWgO+ZkexwB4Z7T5Puk2HRU2VKj0s7bc AFnaGGk27vTjdE/WXtYBN6F3r3nC6g/yxMohQGeyxLxDGfDErme/DoxAbF+9MbOghZ1x XPxljV3f9Joexc6VVXtBPJJn1WObmcF3cAv3EuiX6Q+EDqaZZaCkTNIckLvvqttEQ4UG LmkA== X-Gm-Message-State: AODbwcAch2popO9juRRAbeFo2cA/2iLg7kOS0jE4roeTKALTPERSMgYo xaCILnB+Zvxsfsai7gOy82batOfL7Q== X-Received: by 10.237.52.99 with SMTP id w90mr10661957qtd.19.1496768372364; Tue, 06 Jun 2017 09:59:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.55.104.86 with HTTP; Tue, 6 Jun 2017 09:59:31 -0700 (PDT) In-Reply-To: References: <20170604155212.GA8692@gmail.com> From: "H.J. Lu" Date: Tue, 06 Jun 2017 16:59:00 -0000 Message-ID: Subject: Re: RFC: [PATCH] Add warn_if_not_aligned attribute To: Martin Sebor Cc: Joseph Myers , GCC Patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00348.txt.bz2 On Tue, Jun 6, 2017 at 9:10 AM, Martin Sebor wrote: > 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 Isn't -Waddress-of-packed-member a subset of or the same as -Wpacked? -- H.J.