void -> char cast

Vincent Lefevre vincent at vinc17.net
Thu Jan 9 12:44:09 UTC 2014


On 2014-01-09 10:44:46 +0100, Torbjorn Granlund wrote:
> Conor Williams <conor.williams at gmail.com> writes:
> 
>   Ubuntu - found when compiling with g++
>   
>   will51 at skynet:~/LPS!/lpsb/gmp-5.1.3/demos/expr$ diff exprfa.c exprfa.c.orig
>   122c122
>   <   edup = (char *)(*allocate_func) (i+1);
>   ---
>   >   edup = (*allocate_func) (i+1);
>   
>   
>   will51 at skynet:~/LPS!/lpsb/gmp-5.1.3/demos/expr$ diff exprza.c.orig exprza.c
>   51c51
>   <   edup = (*allocate_func) (i+1);
>   ---
>   >   edup = (char *)(*allocate_func) (i+1);
>   
> You sent the above to the GMP bug reports mailing list.  Are we to
> interpret it as a bug report?  I just see two patches (one apparently
> backwards) with no explaation for what they are supposed to fix.

Conor's bug report is not very good, but I think that this is quite
clear: the cast to (char *), needed by C++ compilers, is missing
here, while always present in the source of the library itself.
It seems that the same thing as in mpz/get_str.c[*] (for instance)
should be done.

[*] mpz/get_str.c, line 70:
      res_str = (char *) (*__gmp_allocate_func) (alloc_size);

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the gmp-bugs mailing list