From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 103669 invoked by alias); 15 Jul 2017 16:33:57 -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 103654 invoked by uid 89); 15 Jul 2017 16:33:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=convinced, HTo:D*cn, HTo:D*edu.cn, Hx-languages-length:664 X-HELO: ainaz.pair.com Received: from ainaz.pair.com (HELO ainaz.pair.com) (209.68.2.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 15 Jul 2017 16:33:53 +0000 Received: from ainaz.pair.com (localhost [127.0.0.1]) by ainaz.pair.com (Postfix) with ESMTP id 0E0673F66E; Sat, 15 Jul 2017 12:33:52 -0400 (EDT) Received: from anthias (vie-188-118-244-226.dsl.sil.at [188.118.244.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ainaz.pair.com (Postfix) with ESMTPSA id 281943F66D; Sat, 15 Jul 2017 12:33:50 -0400 (EDT) Date: Sat, 15 Jul 2017 16:33:00 -0000 From: Gerald Pfeifer To: Xi Ruoyao cc: Martin Sebor , gcc-patches@gcc.gnu.org Subject: Re: [PATCH 2/6] New warnings -Wstring-plus-{char, int} (PR c++/62181) In-Reply-To: <1498127169.16226.1.camel@stu.xidian.edu.cn> Message-ID: References: <1497230800.27153.4.camel@stu.xidian.edu.cn> <1497231174.27153.9.camel@stu.xidian.edu.cn> <699bc809-8e5f-b908-7b2e-0dd036a09462@gmail.com> <1497893292.8943.1.camel@stu.xidian.edu.cn> <7c4365db-fed6-f4c5-1231-2d8ac271fbe6@gmail.com> <1498127169.16226.1.camel@stu.xidian.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; CHARSET=US-ASCII X-IsSubscribed: yes X-SW-Source: 2017-07/txt/msg00888.txt.bz2 On Thu, 22 Jun 2017, Xi Ruoyao wrote: > I created PR 81172. For const char *p = "123" + 'c' we should have: > > warning: offset 99 is above array bounds, the behaviour is > undefined [-Warray-bounds] > const char *p = "123" + 'c'; > > and perhaps (for the case the pointer operand is a string or a string > pointer): > note: adding integer to a string does not append to the string. I do think this makes sense. I'm really not convinced there is a lot of code out there that uses the "123" + i idiom to create a pointer, even if it is legitimate code, so a warning makes sense to me. Gerald