From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 7D7E73857C67 for ; Wed, 21 Oct 2020 07:30:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7D7E73857C67 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mliska@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 8EFD6ADE0 for ; Wed, 21 Oct 2020 07:30:24 +0000 (UTC) From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH][pushed] libsanitizer: add test-case To: gcc-patches@gcc.gnu.org References: <19b37780-58a2-57e3-c338-6239263d9e7b@suse.cz> Message-ID: Date: Wed, 21 Oct 2020 09:30:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.2 MIME-Version: 1.0 In-Reply-To: <19b37780-58a2-57e3-c338-6239263d9e7b@suse.cz> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Oct 2020 07:30:26 -0000 And here I'm adding a test-case for the PR. Thanks, Martin gcc/testsuite/ChangeLog: PR sanitizer/97414 * g++.dg/asan/pr97414.C: New test. --- gcc/testsuite/g++.dg/asan/pr97414.C | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 gcc/testsuite/g++.dg/asan/pr97414.C diff --git a/gcc/testsuite/g++.dg/asan/pr97414.C b/gcc/testsuite/g++.dg/asan/pr97414.C new file mode 100644 index 00000000000..6ea03906daa --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/pr97414.C @@ -0,0 +1,19 @@ +/* PR sanitizer/97414 */ +/* { dg-do run } */ +/* { dg-set-target-env-var ASAN_OPTIONS "detect_invalid_pointer_pairs=1:halt_on_error=1,detect_stack_use_after_return=1" } */ +/* { dg-options "-fsanitize=address,pointer-compare,pointer-subtract" } */ + +[[gnu::noinline]] auto pointer_diff(const int *begin, const int *end) { + return end - begin; +} + +int main() { + constexpr auto size = (2048 / sizeof(int)) + 1; + + auto buf = new int[size]; + auto end = buf + size; + pointer_diff(end, buf); + delete[] buf; + + return 0; +} -- 2.28.0