From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78652 invoked by alias); 23 Feb 2018 16:49:34 -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 78638 invoked by uid 89); 23 Feb 2018 16:49:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-12.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 Feb 2018 16:49:32 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E540040744C6 for ; Fri, 23 Feb 2018 16:49:30 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-85.brq.redhat.com [10.40.204.85]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8B6510AF9E8 for ; Fri, 23 Feb 2018 16:49:29 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w1NGPYLX022560; Fri, 23 Feb 2018 17:25:34 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w1NGPVJL022559; Fri, 23 Feb 2018 17:25:31 +0100 Date: Fri, 23 Feb 2018 16:49:00 -0000 From: Jakub Jelinek To: Jeff Law , Rainer Orth , Mike Stump , Martin Sebor Cc: Siddhesh Poyarekar , Gcc Patch List Subject: Re: [PATCH] correct -Wrestrict handling of arrays of arrays (PR 84095) Message-ID: <20180223162530.GB5867@tucnak> Reply-To: Jakub Jelinek References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg01337.txt.bz2 On Fri, Feb 23, 2018 at 08:52:19AM -0700, Martin Sebor wrote: > There are a large number of failures in these reports in many > tests that were reported previously (before r257910), suggesting > something else is wrong. They all seem to use -fpic. > > If you referring to some other report or your own result please > post a link or say what target/configuration, etc.. The testcase clearly relies on inlining all the wrap_* functions, but as they are void wrap_* with -fpic/-fPIC obviously they can't be inlined at -O2, the executable or some other shared library might define some other implementation of those and interpose it. Some targets default to -fpic even. The following patch just adds static inline to them, so that it works even with -fpic, as tested with: make check-gcc check-g++ RUNTESTFLAGS='--target_board=unix\{,-fpic,-fpie\} dg.exp=Warray-bounds*' Ok for trunk? 2018-02-23 Jakub Jelinek * c-c++-common/Warray-bounds-2.c (wrap_memcpy_src_xsize, wrap_memcpy_src_diff_max, wrap_memcpy_dst_xsize, wrap_memcpy_dst_diff_max, wrap_strcat_src_xsize, wrap_strcat_dst_xsize, wrap_strcpy_src_xsize, wrap_strcpy_dst_xsize, wrap_strncpy_src_xsize, wrap_strncpy_src_diff_max, wrap_strncpy_dst_xsize, wrap_strncpy_dst_diff_max, wrap_strncpy_dstarray_diff_neg): Add static inline. --- gcc/testsuite/c-c++-common/Warray-bounds-2.c.jj 2017-12-18 14:57:15.601127538 +0100 +++ gcc/testsuite/c-c++-common/Warray-bounds-2.c 2018-02-23 17:12:47.114113757 +0100 @@ -1,4 +1,4 @@ -/* Test to exercise that -Warray-bounds warnings for memory and sring +/* Test to exercise that -Warray-bounds warnings for memory and string functions are issued even when they are declared in system headers (i.e., not just when they are explicitly declared in the source file.) @@ -24,7 +24,7 @@ struct __attribute__ ((packed)) Array /* Exercise memcpy out-of-bounds offsets with an array of known size. */ -void wrap_memcpy_src_xsize (char *d, const char *s, ptrdiff_t i, size_t n) +static inline void wrap_memcpy_src_xsize (char *d, const char *s, ptrdiff_t i, size_t n) { memcpy (d, s + i, n); /* { dg-warning "offset 46 is out of the bounds \\\[0, 45] of object .ar. with type .(struct )?Array." "memcpy" } */ } @@ -39,7 +39,7 @@ void call_memcpy_src_xsize (char *d, siz /* Exercise memcpy out-of-bounds offsets with an array of unknown size. */ -void wrap_memcpy_src_diff_max (char *d, const char *s, ptrdiff_t i, size_t n) +static inline void wrap_memcpy_src_diff_max (char *d, const char *s, ptrdiff_t i, size_t n) { memcpy (d, s + i, n); /* { dg-warning "pointer overflow between offset \[0-9\]+ and size 3" "memcpy" } */ } @@ -49,7 +49,7 @@ void call_memcpy_src_diff_max (char *d, wrap_memcpy_src_diff_max (d, s, MAX, 3); } -void wrap_memcpy_dst_xsize (char *d, const char *s, ptrdiff_t i, size_t n) +static inline void wrap_memcpy_dst_xsize (char *d, const char *s, ptrdiff_t i, size_t n) { memcpy (d + i, s, n); /* { dg-warning "offset 47 is out of the bounds \\\[0, 45] of object .ar1. with type .(struct )?Array." "memcpy" } */ } @@ -62,7 +62,7 @@ void call_memcpy_dst_xsize (const char * sink (&ar1); } -void wrap_memcpy_dst_diff_max (char *d, const char *s, ptrdiff_t i, size_t n) +static inline void wrap_memcpy_dst_diff_max (char *d, const char *s, ptrdiff_t i, size_t n) { memcpy (d + i, s, n); /* { dg-warning "offset -?\[0-9\]+ is out of the bounds \\\[0, 45] of object .ar2. with type .(struct )?Array." "memcpy" } */ } @@ -76,7 +76,7 @@ void call_memcpy_dst_diff_max (const cha } -void wrap_strcat_src_xsize (char *d, const char *s, ptrdiff_t i) +static inline void wrap_strcat_src_xsize (char *d, const char *s, ptrdiff_t i) { strcat (d, s + i); /* { dg-warning "offset 46 is out of the bounds \\\[0, 45] of object .ar3. with type .(struct )?Array." "strcat" } */ } @@ -89,7 +89,7 @@ void call_strcat_src_xsize (char *d) sink (&ar3); } -void wrap_strcat_dst_xsize (char *d, const char *s, ptrdiff_t i) +static inline void wrap_strcat_dst_xsize (char *d, const char *s, ptrdiff_t i) { strcat (d + i, s); /* { dg-warning "offset 47 is out of the bounds \\\[0, 45] of object .ar4. with type .(struct )?Array." "strcat" } */ } @@ -103,7 +103,7 @@ void call_strcat_dst_xsize (const char * } -void wrap_strcpy_src_xsize (char *d, const char *s, ptrdiff_t i) +static inline void wrap_strcpy_src_xsize (char *d, const char *s, ptrdiff_t i) { strcpy (d, s + i); /* { dg-warning "offset 48 is out of the bounds \\\[0, 45] of object .ar5. with type .(struct )?Array." "strcpy" } */ } @@ -116,7 +116,7 @@ void call_strcpy_src_xsize (char *d) sink (&ar5); } -void wrap_strcpy_dst_xsize (char *d, const char *s, ptrdiff_t i) +static inline void wrap_strcpy_dst_xsize (char *d, const char *s, ptrdiff_t i) { strcpy (d + i, s); /* { dg-warning "offset 49 is out of the bounds \\\[0, 45] of object .ar6. with type .(struct )?Array." "strcpy" } */ } @@ -132,7 +132,7 @@ void call_strcpy_dst_xsize (const char * /* Exercise strncpy out-of-bounds offsets with an array of known size. */ -void wrap_strncpy_src_xsize (char *d, const char *s, ptrdiff_t i, size_t n) +static inline void wrap_strncpy_src_xsize (char *d, const char *s, ptrdiff_t i, size_t n) { strncpy (d, s + i, n); /* { dg-warning "offset 46 is out of the bounds \\\[0, 45] of object .ar7. with type '(struct )?Array." "strncpy" } */ } @@ -147,7 +147,7 @@ void call_strncpy_src_xsize (char *d, si /* Exercise strncpy out-of-bounds offsets with an array of unknown size. */ -void wrap_strncpy_src_diff_max (char *d, const char *s, ptrdiff_t i, size_t n) +static inline void wrap_strncpy_src_diff_max (char *d, const char *s, ptrdiff_t i, size_t n) { /* Unlike in the similar call to memcpy(), there is no pointer overflow here because the size N is not added to the source @@ -160,7 +160,7 @@ void call_strncpy_src_diff_max (char *d, wrap_strncpy_src_diff_max (d, s, MAX, 3); } -void wrap_strncpy_dst_xsize (char *d, const char *s, ptrdiff_t i, size_t n) +static inline void wrap_strncpy_dst_xsize (char *d, const char *s, ptrdiff_t i, size_t n) { strncpy (d + i, s, n); /* { dg-warning "offset 47 is out of the bounds \\\[0, 45] of object .ar8. with type .(struct )?Array." "strncpy" } */ } @@ -173,7 +173,7 @@ void call_strncpy_dst_xsize (const char sink (&ar8); } -void wrap_strncpy_dst_diff_max (char *d, const char *s, ptrdiff_t i, size_t n) +static inline void wrap_strncpy_dst_diff_max (char *d, const char *s, ptrdiff_t i, size_t n) { strncpy (d + i, s, n); /* { dg-warning "offset -\[0-9\]+ is out of the bounds \\\[0, 45] of object .ar9. with type .(struct )?Array." "strncpy" } */ } @@ -186,8 +186,7 @@ void call_strncpy_dst_diff_max (const ch sink (&ar9); } -void wrap_strncpy_dstarray_diff_neg (char *d, const char *s, ptrdiff_t i, - size_t n) +static inline void wrap_strncpy_dstarray_diff_neg (char *d, const char *s, ptrdiff_t i, size_t n) { strncpy (d + i, s, n); /* { dg-warning "offset -\[0-9\]+ is out of the bounds \\\[0, 90] of object .ar10. with type .(struct )?Array ?\\\[2]." "strncpy" } */ } Jakub