From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id E29493851C11 for ; Tue, 30 Jun 2020 13:59:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E29493851C11 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-388-oirD9dquPp2Bu260EHWa9A-1; Tue, 30 Jun 2020 09:59:01 -0400 X-MC-Unique: oirD9dquPp2Bu260EHWa9A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 038BA10A8A23 for ; Tue, 30 Jun 2020 13:58:02 +0000 (UTC) Received: from blade.nx (ovpn-114-100.ams2.redhat.com [10.36.114.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBCC4B3A7B for ; Tue, 30 Jun 2020 13:58:01 +0000 (UTC) Received: from blade.com (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id 0EE97816CCA9 for ; Tue, 30 Jun 2020 14:58:01 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Subject: [PATCH] Make out of range type conversions explicit Date: Tue, 30 Jun 2020 14:58:00 +0100 Message-Id: <1593525480-5685-1-git-send-email-gbenson@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jun 2020 13:59:06 -0000 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; } -- 1.8.3.1