lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> > It was thus said that the Great Irfan Adilovic once stated:
> > > In the 5.3.3 release, lua/
> > > 
> > >     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.

BTW, we always use -Wmissing-prototypes plus -Wstrict-prototypes and
-Wold-style-definition and -Wc++-compat. This last one should have
warned us about this particular problem:

	-Wc++-compat (C and Objective-C only)
	  Warn about ISO C constructs that are outside of the common subset
	  of ISO C and ISO C++, e.g. request for implicit conversion from
	  "void *" to a pointer to non-"void" type.

gcc correctly flags this problem, but clang does not, even though
it gladly accepts the option. (We have been using clang lately, and
we apparently failed to check 5.3.3 releases with gcc...)

-- Roberto