* [PATCH] gdb/x86: Fix `-Wstrict-overflow' build error in `i387_collect_xsave'
@ 2018-05-15 14:45 Maciej W. Rozycki
2018-05-22 11:15 ` [PING][PATCH] " Maciej W. Rozycki
0 siblings, 1 reply; 3+ messages in thread
From: Maciej W. Rozycki @ 2018-05-15 14:45 UTC (permalink / raw)
To: gdb-patches; +Cc: Andrew Burgess, gcc
Make `i' defined within `i387_collect_xsave' unsigned, removing a
`-Werror=strict-overflow' compilation error:
.../gdb/i387-tdep.c: In function 'void i387_collect_xsave(const regcache*, int, void*, int)':
.../gdb/i387-tdep.c:1348:1: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow]
i387_collect_xsave (const struct regcache *regcache, int regnum,
^
cc1plus: all warnings being treated as errors
Makefile:1610: recipe for target 'i387-tdep.o' failed
make: *** [i387-tdep.o] Error 1
seen with GCC 5.4.0, a commit 8ee22052f690 ("gdb/x86: Handle kernels
using compact xsave format") regression. While `regnum' can be -1 on
entry to the function, to mean all registers, `i' is only used with
non-negative register numbers.
gdb/
* i387-tdep.c (i387_collect_xsave): Make `i' unsigned.
---
Hi,
I believe this comes from register numbers being retrieved from the
`tdep' structure at run time and therefore making the compiler unable to
statically determine in loop expression processing that the calculations
made on `i' will not cause a signed overflow.
NB the error message pointing at the function definition rather than the
declaration of `i' makes it rather difficult to determine what the actual
cause might be. I just hope it's only a peculiarity of the somewhat older
version of the compiler and it has been fixed since. Could someone from
the GCC mailing list please comment on that?
OK to apply?
Maciej
---
gdb/i387-tdep.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
gdb-i387-collect-xsave-signed-overflow.diff
Index: gdb/gdb/i387-tdep.c
===================================================================
--- gdb.orig/gdb/i387-tdep.c 2018-05-10 22:13:05.000000000 +0100
+++ gdb/gdb/i387-tdep.c 2018-05-13 23:27:46.194412211 +0100
@@ -1354,7 +1354,7 @@ i387_collect_xsave (const struct regcach
gdb_byte *p, *regs = (gdb_byte *) xsave;
gdb_byte raw[I386_MAX_REGISTER_SIZE];
ULONGEST initial_xstate_bv, clear_bv, xstate_bv = 0;
- int i;
+ unsigned int i;
enum
{
x87_ctrl_or_mxcsr = 0x1,
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PING][PATCH] gdb/x86: Fix `-Wstrict-overflow' build error in `i387_collect_xsave'
2018-05-15 14:45 [PATCH] gdb/x86: Fix `-Wstrict-overflow' build error in `i387_collect_xsave' Maciej W. Rozycki
@ 2018-05-22 11:15 ` Maciej W. Rozycki
2018-05-22 13:34 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Maciej W. Rozycki @ 2018-05-22 11:15 UTC (permalink / raw)
To: gdb-patches; +Cc: Andrew Burgess, gcc
On Tue, 15 May 2018, Maciej W. Rozycki wrote:
> gdb/
> * i387-tdep.c (i387_collect_xsave): Make `i' unsigned.
Ping for: <https://patchwork.sourceware.org/patch/27269/>.
Maciej
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PING][PATCH] gdb/x86: Fix `-Wstrict-overflow' build error in `i387_collect_xsave'
2018-05-22 11:15 ` [PING][PATCH] " Maciej W. Rozycki
@ 2018-05-22 13:34 ` Pedro Alves
0 siblings, 0 replies; 3+ messages in thread
From: Pedro Alves @ 2018-05-22 13:34 UTC (permalink / raw)
To: Maciej W. Rozycki, gdb-patches; +Cc: Andrew Burgess, gcc
On 05/22/2018 12:14 PM, Maciej W. Rozycki wrote:
> On Tue, 15 May 2018, Maciej W. Rozycki wrote:
>
>> gdb/
>> * i387-tdep.c (i387_collect_xsave): Make `i' unsigned.
>
> Ping for: <https://patchwork.sourceware.org/patch/27269/>.
OK.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-22 13:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-15 14:45 [PATCH] gdb/x86: Fix `-Wstrict-overflow' build error in `i387_collect_xsave' Maciej W. Rozycki
2018-05-22 11:15 ` [PING][PATCH] " Maciej W. Rozycki
2018-05-22 13:34 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).