This is the mail archive of the
mailing list for the binutils project.
Re: Unable to build gas/config/tc-riscv.c
- From: Palmer Dabbelt <palmer at dabbelt dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: binutils at sourceware dot org
- Date: Mon, 03 Apr 2017 09:15:29 -0700 (PDT)
- Subject: Re: Unable to build gas/config/tc-riscv.c
- Authentication-results: sourceware.org; auth=none
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:
Author: Palmer Dabbelt <email@example.com>
Date: Mon Apr 3 09:03:57 2017 -0700
RISC-V: Avoid a const warning
2017-04-03 Palmer Dabbelt <firstname.lastname@example.org>
* 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
@@ -1,3 +1,8 @@
+2017-04-03 Palmer Dabbelt <email@example.com>
+ * config/tc-riscv.c (riscv_clear_subsets): Cast argument to free to
+ avoid const warnings.
2017-03-30 Palmer Dabbelt <firstname.lastname@example.org>
* 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
@@ -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);
riscv_subsets = next;