* [RFA] Cast char constant to int in sizeof.exp
@ 2017-09-06 4:53 Tom Tromey
2017-09-06 14:29 ` Pedro Alves
0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2017-09-06 4:53 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
PR gdb/22010 concerns a regression I introduced with the scalar
printing changes. The bug is that this code in sizeof.exp:
set signof_byte [get_integer_valueof "(int) '\\377'" -1]
can incorrectly compute sizeof_byte. One underlying problem here is
that gdb's C parser doesn't treat a char constant as an int (this is
PR 19973).
However, it seems good to have an immediate fix for the regression.
The simplest is to cast to an int here.
testsuite/ChangeLog
2017-09-05 Tom Tromey <tom@tromey.com>
PR gdb/22010:
* gdb.base/sizeof.exp (check_valueof): Cast char constant to int.
---
gdb/testsuite/ChangeLog | 5 +++++
gdb/testsuite/gdb.base/sizeof.exp | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index b3bed5c..01c6249 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2017-09-05 Tom Tromey <tom@tromey.com>
+ PR gdb/22010:
+ * gdb.base/sizeof.exp (check_valueof): Cast char constant to int.
+
+2017-09-05 Tom Tromey <tom@tromey.com>
+
* lib/gdb.exp (gdb_compile): Don't use universal_compile_options
for rust.
diff --git a/gdb/testsuite/gdb.base/sizeof.exp b/gdb/testsuite/gdb.base/sizeof.exp
index 5d89407..13d36f8 100644
--- a/gdb/testsuite/gdb.base/sizeof.exp
+++ b/gdb/testsuite/gdb.base/sizeof.exp
@@ -86,7 +86,7 @@ proc check_valueof { exp val } {
# Check that GDB and the target agree over the sign of a character.
-set signof_byte [get_integer_valueof "'\\377'" -1]
+set signof_byte [get_integer_valueof "(int) '\\377'" -1]
set signof_char [get_integer_valueof "(int) (char) -1" -1]
set signof_signed_char [get_integer_valueof "(int) (signed char) -1" -1]
set signof_unsigned_char [get_integer_valueof "(int) (unsigned char) -1" -1]
--
2.9.4
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [RFA] Cast char constant to int in sizeof.exp
2017-09-06 4:53 [RFA] Cast char constant to int in sizeof.exp Tom Tromey
@ 2017-09-06 14:29 ` Pedro Alves
0 siblings, 0 replies; 2+ messages in thread
From: Pedro Alves @ 2017-09-06 14:29 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 09/06/2017 05:53 AM, Tom Tromey wrote:
> PR gdb/22010 concerns a regression I introduced with the scalar
> printing changes. The bug is that this code in sizeof.exp:
>
> set signof_byte [get_integer_valueof "(int) '\\377'" -1]
The cast shouldn't be here in the log. The cast is what fixes it.
>
> can incorrectly compute sizeof_byte. One underlying problem here is
> that gdb's C parser doesn't treat a char constant as an int (this is
> PR 19973).
>
> However, it seems good to have an immediate fix for the regression.
> The simplest is to cast to an int here.
>
> testsuite/ChangeLog
> 2017-09-05 Tom Tromey <tom@tromey.com>
>
> PR gdb/22010:
> * gdb.base/sizeof.exp (check_valueof): Cast char constant to int.
OK.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-06 14:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-06 4:53 [RFA] Cast char constant to int in sizeof.exp Tom Tromey
2017-09-06 14:29 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox