From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116275 invoked by alias); 2 Sep 2017 22:50:19 -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 116266 invoked by uid 89); 2 Sep 2017 22:50:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=sk:documen X-HELO: mail-qt0-f177.google.com Received: from mail-qt0-f177.google.com (HELO mail-qt0-f177.google.com) (209.85.216.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 02 Sep 2017 22:50:13 +0000 Received: by mail-qt0-f177.google.com with SMTP id w42so12357690qtg.5 for ; Sat, 02 Sep 2017 15:50:13 -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=3icy897ShhKsqd5QeKcoLX8cuRGW0hNIKEzVW0mDl3Q=; b=c9KAWoz4cko9WoxJ+gu1cvXcoXtJFv1eoiX1s7q+9vrs2YwSQOROaHFNKu+trtN/mg qScoB++KA6mF79UOErP3BRJhG3l53QeJs6KDSocb/BBnN97VUywql+pkNm9qQAGyXWqj C+4mz+9nbCggO74jeyPXSkzFD3htcqtkGaKMpCt4Tvx1d01UAnyvtyASA/ZOnHBDsIEG T8umAlPDDBQ9DQrgaC0qt4BaPUHzM2B8DEzJmd9CmiFdFTYCjyXML6eAhYTkezFqMA3q Pnv5860g41oN7eZUbAqewfFiAYPRLzgvpSdT9TBtLvZ3OTHTr5wELCOXq0+S11rCiFEe NMIA== X-Gm-Message-State: AHPjjUjy2IG8pDo7AWxdWruDC01Qy+kXPSjE9JbvE9toGgAxa6Od5OBZ v+CR9c/7cN5LRQ== X-Google-Smtp-Source: ADKCNb45O4xoFws7BXC1ly6BP/iV3V7YO4vpcDM7Hx73nkvuP2Reffn54k7cyOs8x6m6aruzQVH03A== X-Received: by 10.200.51.3 with SMTP id t3mr9335107qta.67.1504392612076; Sat, 02 Sep 2017 15:50:12 -0700 (PDT) Received: from localhost.localdomain (174-16-125-25.hlrn.qwest.net. [174.16.125.25]) by smtp.gmail.com with ESMTPSA id s185sm1521153qkf.0.2017.09.02.15.50.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Sep 2017 15:50:11 -0700 (PDT) Subject: [PING] [PATCH] detect incompatible aliases (PR c/81854) To: Gcc Patch List , Jeff Law References: Cc: Joseph Myers From: Martin Sebor Message-ID: <52e4bed3-ccc3-56c2-89c0-9dfc0562418b@gmail.com> Date: Sat, 02 Sep 2017 22:50: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-09/txt/msg00110.txt.bz2 Jeff, this is the other attribute patch I mentioned the other day: https://gcc.gnu.org/ml/gcc-patches/2017-08/msg01103.html The Glibc and libstdc++ changes have already been committed: https://sourceware.org/ml/glibc-cvs/2017-q3/msg00587.html https://gcc.gnu.org/ml/gcc-cvs/2017-08/msg00459.html Thanks Martin On 08/17/2017 09:21 PM, Martin Sebor wrote: > Joseph, while looking into implementing enhancement your request > pr81824 I noticed that GCC silently accepts incompatible alias > declarations (pr81854) so as sort of a proof-concept for the > former I enhanced the checking already done for other kinds of > incompatibilities to also detect those mentioned in the latter > bug. Attached is this patch, tested on x85_64-linux. > > Jonathan, the patch requires suppressing the warning in libstdc++ > compatibility symbol definitions in compatibility.cc. I couldn't > find a way to do it without the suppression but I'd be happy to > try again if you have an idea for how. > > As an example, the patch lets GCC detect mistakes like: > > size_t __attribute__ ((ifunc ("bar_resolver"))) > bar (void*, const void*, size_t); > > void* fast_bar (void *d, const void *s, size_t n) { ... } > void* slow_bar (void *d, const void *s, size_t n) { ... } > > void* bar_resolver (void) > { > return fast ? &fast_bar : &slow_bar; > } > > By complaining that the ifunc resolver should return a function > pointer it makes the programmer change the declaration of the > resolver to one of: > > __typeof__ (bar)* bar_resolver (void) { ... } > > or > > __typeof__ (fast_bar)* bar_resolver (void) { ... } > > which then triggers either -Wincompatible-pointer-types or > -Wattributes, respectively. (I used the latter warning in > my patch but maybe the former would be more appropriate). > > Martin > > PS A documentation-only patch to update the description of > attribute ifunc was posted separately here: > https://gcc.gnu.org/ml/gcc-patches/2017-08/msg01095.html > > PPS To make use of this checking (and compile without the new > warnings) Glibc needs the following patch: > > diff --git a/include/libc-symbols.h b/include/libc-symbols.h > index fe3ab81..5413e56 100644 > --- a/include/libc-symbols.h > +++ b/include/libc-symbols.h > @@ -790,7 +790,8 @@ for linking") > > /* Helper / base macros for indirect function symbols. */ > #define __ifunc_resolver(type_name, name, expr, arg, init, classifier) \ > - classifier inhibit_stack_protector void *name##_ifunc (arg) > \ > + classifier inhibit_stack_protector \ > + __typeof (type_name) *name##_ifunc (arg) \ > { \ > init (); \ > __typeof (type_name) *res = expr; \ >