From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 126678 invoked by alias); 11 Oct 2016 21:27:27 -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 126667 invoked by uid 89); 11 Oct 2016 21:27:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.2 spammy= X-HELO: mail-oi0-f44.google.com Received: from mail-oi0-f44.google.com (HELO mail-oi0-f44.google.com) (209.85.218.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Oct 2016 21:27:16 +0000 Received: by mail-oi0-f44.google.com with SMTP id t73so39858289oie.1 for ; Tue, 11 Oct 2016 14:27:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ZyJB8hJkASE612ePclKosABIM3YD0mbJ4j0XCjvECGE=; b=kqLx9Vx43O3AXSK3wmOUaZ6czu/OTkJzsuMlw5FpxXFvPeQG4VVzf4Z8PXGA8jQxgO wMtjqK9/bHNUycPTQcgyQShum7QDlr9RshenY8ZN9IlG78onSweS0HEq2aMSm7uvF71/ vC8G+eW56GiktOCfQ6j37C0tZJbqmr9Apzdy2yMWsCi1n3ZbnI8xbuRlK9CIimhZLQHe 1JdvOt8pJ/a7WLRZiWxoCAdaPSm8rCt8N3kbCVEBbGq+UQep8sfPq9qO319dyOHJytP0 JQRmaztJudaqsBH06mSnaNFfPUskybcyCXpkoF3+7KcZ64LIJoWaazUtlN6H4JY12Fo8 nD4Q== X-Gm-Message-State: AA6/9Rn9BBHI0KACwqizFuF2sAqq8lAzuNCEwrpnFYrt4H2bwzQwo2MplDo5J35W7yHpk0Kf0NZ2SzVIkHt5Jftx X-Received: by 10.157.34.18 with SMTP id o18mr2933724ota.112.1476221234994; Tue, 11 Oct 2016 14:27:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.87.231 with HTTP; Tue, 11 Oct 2016 14:26:54 -0700 (PDT) In-Reply-To: References: From: Jason Merrill Date: Tue, 11 Oct 2016 21:27:00 -0000 Message-ID: Subject: Re: [PATCH] Implement new hook for max_align_t_align To: John David Anglin Cc: DJ Delorie , Bernd Edlinger , gcc-patches List , Jeff Law Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg00786.txt.bz2 On Tue, Oct 11, 2016 at 4:54 PM, John David Anglin wrote: > On 2016-10-11 4:11 PM, Jason Merrill wrote: >> >> On Tue, Oct 11, 2016 at 2:59 PM, DJ Delorie wrote: >>> >>> Jason Merrill writes: >>>> >>>> If PA malloc doesn't actually provide 16-byte alignment, this change >>>> seems problematic; it will mean any type that wants 16-byte alignment >>>> will silently get 8-byte alignment instead. >>> >>> Should such cases be calling memalign (or posix_memalign) instead of >>> malloc? >> >> We're talking about this in the context of C++17 aligned new, which >> uses one of those functions (or C aligned_alloc) under the hood. >> Currently on PA, allocating one of these types with 'new' in C++14 >> mode gives a warning because the compiler doesn't think the allocation >> will actually provide the 16-byte alignment that the type wants. This >> warning seems to be correct. This patch would silence that warning by >> pretending that malloc will provide 16-byte alignment, which is not >> actually true. > > But the check isn't directly about malloc. It's between the alignment for > max_align_t and the alignment that the type wants. Joseph indicated that max_align_t > should have an alignment as large as the POSIX types (e.g., pthread_mutex_t). So, I think > setting it to 16 when pthread_mutex_t wants an alignment of 16 is correct. The connection to max_align_t is just a GCC implementation detail; the C++ standard doesn't tie use of aligned new to alignof(max_align_t), there's a separate macro __STDCPP_DEFAULT_NEW_ALIGNMENT__. This was done specifically to allow for the case where malloc for a target provides more alignment than max_align_t. But that still doesn't help with this case, where in fact the warning is correct, you just know it isn't a problem. So disabling the warning on PA seems like the way to go. Jason