This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] [gold] Fix integer narrowing in switch
- From: Cary Coutant <ccoutant at gmail dot com>
- To: Roland McGrath <mcgrathr at google dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Mon, 6 Aug 2018 13:49:05 -0700
- Subject: Re: [PATCH] [gold] Fix integer narrowing in switch
- References: <CAB=4xhpTA_3wKTUX4j7cc1Ptd-tFoQ3tKhXUMYxXZ5AK4hh1Sw@mail.gmail.com>
Thanks, Roland! I already had the fix ready to push, though. BTW, the
first operand should also be unsigned int.
-cary
On Fri, Aug 3, 2018 at 2:44 PM, Roland McGrath via binutils
<binutils@sourceware.org> wrote:
> Some of the enum constants in the switch are too large for signed int.
> With recent Clang, this gets an error about C++11 integer narrowing rules.
> Everywhere else uses unsigned int for pr_type, so Target should too.
>
> OK for trunk and 2.31 branch?
>
>
> Thanks,
> Roland
>
>
> gold/
> 2018-08-03 Roland McGrath <mcgrathr@google.com>
>
> * target.h (Sized_target::record_gnu_property): Use unsigned int
> for second argument.
> * x86_64.cc (Target_x86_64<size>::record_gnu_property): Likewise.
>
> diff --git a/gold/target.h b/gold/target.h
> index bb312067b5f..00a1f988e7a 100644
> --- a/gold/target.h
> +++ b/gold/target.h
> @@ -1147,7 +1147,8 @@ class Sized_target : public Target
> // Record a target-specific program property in the .note.gnu.property
> // section.
> virtual void
> - record_gnu_property(int, int, size_t, const unsigned char*, const Object*)
> + record_gnu_property(int, unsigned int, size_t, const unsigned char*,
> + const Object*)
> { }
>
> // Merge the target-specific program properties from the current object.
> diff --git a/gold/x86_64.cc b/gold/x86_64.cc
> index 27f273d64b3..36c2c27f5b6 100644
> --- a/gold/x86_64.cc
> +++ b/gold/x86_64.cc
> @@ -1307,7 +1307,8 @@ class Target_x86_64 : public Sized_target<size, false>
> // Record a target-specific program property in the .note.gnu.property
> // section.
> void
> - record_gnu_property(int, int, size_t, const unsigned char*, const Object*);
> + record_gnu_property(int, unsigned int, size_t, const unsigned char*,
> + const Object*);
>
> // Merge the target-specific program properties from the current object.
> void
> @@ -1579,7 +1580,7 @@
> Target_x86_64<size>::rela_irelative_section(Layout* layout)
> template<int size>
> void
> Target_x86_64<size>::record_gnu_property(
> - int, int pr_type,
> + int, unsigned int pr_type,
> size_t pr_datasz, const unsigned char* pr_data,
> const Object* object)
> {