[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [patch][c++] fix "invalid conversion from ‘void*’ to ‘char*’"
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 27 Jun 2016 10:12:52 -0300
> It was thus said that the Great Irfan Adilovic once stated:
> > In the 5.3.3 release, lua/lstrlib.cc:936:
> > char *ppoint = memchr(buff, point, nb);
> > is not valid c++ code. This should be fixed with a c-style cast:
> But it *is* valid C code. In C, it's recommended *not* to cast the result
> of malloc() as it can hide errors (mainly missing declarations---in C,
> without a prototype, the compiler will assume a function returns an int).
We always use -Wmissing-prototypes, so this does not seem to be an
issue. Note that Lua already casts all the result of malloc (see macros
in 'lmem.h')---otherwise there would be lots of errors like this one.