Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Luis Machado <luis.machado@linaro.org>
To: Gary Benson <gbenson@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Make out of range type conversions explicit
Date: Tue, 30 Jun 2020 14:52:08 -0300	[thread overview]
Message-ID: <40e636d7-e938-1351-eb5e-9f92540d9c1a@linaro.org> (raw)
In-Reply-To: <1593525480-5685-1-git-send-email-gbenson@redhat.com>

If the approach is acceptable, we should at least make it clear, through 
comments, that this is being done for clang. Having these casts in the 
code, without an explanation, is a bit cryptic.

On 6/30/20 10:58 AM, Gary Benson via Gdb-patches wrote:
> HI all,
> 
> Clang fails to compile two testcases with the following warning:
> implicit conversion from 'X' to 'Y' changes value from x to y
> [-Wconstant-conversion].  This patch adds casts that make the
> value-changing conversions explicit.
> 
> Checked on Fedora 31 x86_64, GCC and clang.  Ok to commit?
> 
> Cheers,
> Gary
> 
> --
> gdb/testsuite/ChangeLog:
> 
> 	* gdb.base/charset.c (main): Explicitly cast values which are
> 	out of range of their destination types.
> 	* gdb.base/structs2.c (main): Likewise.
> ---
>   gdb/testsuite/ChangeLog           | 6 ++++++
>   gdb/testsuite/gdb.base/charset.c  | 6 +++---
>   gdb/testsuite/gdb.base/structs2.c | 2 +-
>   3 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.base/charset.c b/gdb/testsuite/gdb.base/charset.c
> index ec4927d..54bd2dd 100644
> --- a/gdb/testsuite/gdb.base/charset.c
> +++ b/gdb/testsuite/gdb.base/charset.c
> @@ -141,14 +141,14 @@ int main ()
>                  120,
>                  7, 8, 12,
>                  10, 13, 9,
> -               11, 162, 17);
> +               11, (char) 162, 17);
>     fill_run (iso_8859_1_string, 7, 26, 65);
>     fill_run (iso_8859_1_string, 33, 26, 97);
>     fill_run (iso_8859_1_string, 59, 10, 48);
>   
>     /* Initialize ebcdic_us_string.  */
>     init_string (ebcdic_us_string,
> -               167,
> +               (char) 167,
>                  47, 22, 12,
>                  37, 13, 5,
>                  11, 74, 17);
> @@ -165,7 +165,7 @@ int main ()
>   
>     /* Initialize ibm1047_string.  */
>     init_string (ibm1047_string,
> -               167,
> +               (char) 167,
>                  47, 22, 12,
>                  37, 13, 5,
>                  11, 74, 17);
> diff --git a/gdb/testsuite/gdb.base/structs2.c b/gdb/testsuite/gdb.base/structs2.c
> index 7c8be03..2847cd6 100644
> --- a/gdb/testsuite/gdb.base/structs2.c
> +++ b/gdb/testsuite/gdb.base/structs2.c
> @@ -13,7 +13,7 @@ static void param_reg (register signed char pr_char,
>   
>     bkpt = 0;
>     param_reg (120, 130, 32000, 33000);
> -  param_reg (130, 120, 33000, 32000);
> +  param_reg ((signed char) 130, 120, (short) 33000, 32000);
>   
>     return 0;
>   }
> 


  reply	other threads:[~2020-06-30 17:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30 13:58 Gary Benson
2020-06-30 17:52 ` Luis Machado [this message]
2020-07-02 20:23 ` Pedro Alves
2020-07-03  9:30   ` Gary Benson
2020-07-03 10:42     ` Pedro Alves
2020-07-03 13:09       ` Gary Benson
2020-07-03 14:05         ` Pedro Alves
2020-07-07 11:37           ` Gary Benson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40e636d7-e938-1351-eb5e-9f92540d9c1a@linaro.org \
    --to=luis.machado@linaro.org \
    --cc=gbenson@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox