This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unable to build gas/config/tc-riscv.c

On Mon, 03 Apr 2017 02:43:21 PDT (-0700), Nick Clifton wrote:
> Hi Palmer,
>   I am unable to build tc-riscv.c after your latest update:
> gas/config/tc-riscv.c: In function 'riscv_clear_subsets':
> gas/config/tc-riscv.c:129:13: error: passing argument 1 of 'free' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
>        free (riscv_subsets->name);
>              ^~~~~~~~~~~~~
> In file included from gas/as.h:58:0,
>                  from gas/config/tc-riscv.c:23:
> /usr/include/stdlib.h:444:13: note: expected 'void *' but argument is of type 'const char *'
>  extern void free (void *__ptr) __THROW;
>              ^~~~
>   (I am using gcc v6.3.1 from Fedora 25).
>   I thought about just checking in a patch to add a cast to the free()
>   invocation, but then I wondered if maybe it would be better to change
>   the type in the subsets structure, so I will leave this up to you.
>   Either way, please check in a patch to fix this problem as soon as you
>   can.  Such a patch is pre-approved.

Sorry about that, I must have had --disable-werror when I was testing that.  I
think it's clearer to add the cast to the free call, as you're not expected to
be changing that subset string during normal execution.

I've committed this:

commit 8b1324098451be7d4e06aa3fd99b59a4369ceb24
Author: Palmer Dabbelt <>
Date:   Mon Apr 3 09:03:57 2017 -0700

    RISC-V: Avoid a const warning

    2017-04-03  Palmer Dabbelt  <>

           * config/tc-riscv.c (riscv_clear_subsets): Cast argument to free to
           avoid const warnings.

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 169b2ff..557b43c 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-03  Palmer Dabbelt  <>
+	* config/tc-riscv.c (riscv_clear_subsets): Cast argument to free to
+	avoid const warnings.
 2017-03-30  Palmer Dabbelt  <>

 	* config/tc-riscv.c (riscv_clear_subsets): New function.
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 2830ba1..0a9817a 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -126,7 +126,7 @@ riscv_clear_subsets (void)
   while (riscv_subsets != NULL)
       struct riscv_subset *next = riscv_subsets->next;
-      free (riscv_subsets->name);
+      free ((void *) riscv_subsets->name);
       free (riscv_subsets);
       riscv_subsets = next;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]