From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29113 invoked by alias); 25 Oct 2014 09:44:54 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 29104 invoked by uid 89); 25 Oct 2014 09:44:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f172.google.com Received: from mail-pd0-f172.google.com (HELO mail-pd0-f172.google.com) (209.85.192.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 25 Oct 2014 09:44:52 +0000 Received: by mail-pd0-f172.google.com with SMTP id r10so2804564pdi.31 for ; Sat, 25 Oct 2014 02:44:50 -0700 (PDT) X-Received: by 10.67.23.109 with SMTP id hz13mr10656583pad.48.1414230290713; Sat, 25 Oct 2014 02:44:50 -0700 (PDT) Received: from ShengShiZhuChengdeMacBook-Pro.local ([223.72.65.17]) by mx.google.com with ESMTPSA id qx4sm5821246pbc.14.2014.10.25.02.44.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Oct 2014 02:44:49 -0700 (PDT) Message-ID: <544B727B.1090301@gmail.com> Date: Sat, 25 Oct 2014 09:44:00 -0000 From: Chen Gang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Mark Kettenis CC: palves@redhat.com, ibuclaw@gdcproject.org, brobecker@adacore.com, gdb-patches@sourceware.org Subject: Re: [PATCH v3] gdb/i387-tdep.c: Avoid warning for "-Werror=strict-overflow" References: <543FB512.60607@gmail.com> <544ADA5D.4010507@gmail.com> <201410250912.s9P9CHj4001707@glazunov.sibelius.xs4all.nl> In-Reply-To: <201410250912.s9P9CHj4001707@glazunov.sibelius.xs4all.nl> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-10/txt/msg00695.txt.bz2 On 10/25/14 17:12, Mark Kettenis wrote: >> Date: Sat, 25 Oct 2014 07:01:49 +0800 >> From: Chen Gang >> >> Hell Maintainers: >> >> Is this patch OK, if need additional improvements, please let me know. >> >> By the way: for "I387_MXCSR_REGNUM", I guess, gcc 'think' it is for 2 >> variables, which does not match "(X + c) >= X" ('c' means constant, I >> guess), so gcc does not report warning for it (then I did not touch it). > > No this patch is not ok. It doesn't implement Pedro's suggestion to > rewrite the loops. I started working on that, but then I discovered > that there are many more similar loops where your compiler apparently > doesn't warn about signed overflow in the comparison. Perhaps I'll > finish my diff some day, but it isn't a very high priority for me. > It seems a misunderstanding, for me, Pedro's suggestion is also for avoiding compiling warnings, and his idea is better than others. And just like you said, there are many almost the same using ways within this file, but gcc5 does not report warnings for them. > I don't really want to uglify the code just to make unhelpful > compilers happy. Playing whack-a-mle with GCC isn't my idea of fun. > Neither me. But we can not say that is GCC5' issue, for me: - "(X + c) >= X" may really find some issues which developers missed, so it is still valuable. - gcc treates their warnings are only as the 'advice' for developers, not mandatory. 'advice' must be valuable, but may be not suitable in any cases. - but our gdb wants to treate all 'advice' as mandatory whether it is suitable for us or not. So we have to try to let our code to be 'suitable' for both us and GCC5. > And yes, your compiler is being unhelpful. If it warns about possible > signed overflow in the RHS expression of a comparision, why doesn't it > warn about any signed addition that might overflow? > For me, because they are not match "(X + c) >= X" ('c' is constant). For "-Wstrict-overflow", it includes "(X + c) >= X", but not others. :-( And can we disable "-Wstrict-overflow" (I guess not)? And there is another clearer way, although it may be even more uglier: "#pragma diagnostic ..." Thanks. -- Chen Gang Open, share, and attitude like air, water, and life which God blessed