[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [patch][c++] fix "invalid conversion from ‘void*’ to ‘char*’"
- From: Sean Conner <sean@...>
- Date: Mon, 27 Jun 2016 04:05:13 -0400
It was thus said that the Great Coda Highland once stated:
> On Sun, Jun 26, 2016 at 2:11 PM, Sean Conner <sean@conman.org> wrote:
> > 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).
> >
> >> @@ -935,3 +935,3 @@ static void checkdp (char *buff, int nb) {
> >> char point = lua_getlocaledecpoint(); /* try locale point */
> >> - char *ppoint = memchr(buff, point, nb);
> >> + char *ppoint = (char *)(memchr(buff, point, nb));
> >> if (ppoint) *ppoint = '.'; /* change it to a dot */
> >
> > I would recommend against this patch.
> >
> > -spc (But then again, I program in C, not C++)
> >
> >
>
> This is a .cc file, which means it's compiled as C++ code, which means
> whether or not it's valid C is irrelevant.
And Lua is written in C89, which does *not* need the cast, nor should one
be added by PUC. Unless there's a lstrlib.cc file hiding in the Lua 5.3.3
distribution that I missed ...
-spc (He's compiling a *C* program with a *C++* compiler ... what exactly
is he expecting?)