This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v3] gdb/i387-tdep.c: Avoid warning for "-Werror=strict-overflow"
- From: Chen Gang <gang dot chen dot 5i5j at gmail dot com>
- To: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- Cc: palves at redhat dot com, ibuclaw at gdcproject dot org, brobecker at adacore dot com, gdb-patches at sourceware dot org
- Date: Sat, 25 Oct 2014 17:50:51 +0800
- Subject: Re: [PATCH v3] gdb/i387-tdep.c: Avoid warning for "-Werror=strict-overflow"
- Authentication-results: sourceware.org; auth=none
- References: <543FB512 dot 60607 at gmail dot com> <544ADA5D dot 4010507 at gmail dot com> <201410250912 dot s9P9CHj4001707 at glazunov dot sibelius dot xs4all dot nl>
On 10/25/14 17:12, Mark Kettenis wrote:
>> Date: Sat, 25 Oct 2014 07:01:49 +0800
>> From: Chen Gang <gang.chen.5i5j@gmail.com>
>>
>> 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