On 08/02/17 08:42 +0100, Jakub Jelinek wrote:
On Tue, Feb 07, 2017 at 11:59:33PM +0000, Tom Hughes wrote:
> On 07/02/17 23:56, Stephen John Smoogen wrote:
> > On 7 February 2017 at 18:39, Sérgio Basto <sergio(a)serjux.com> wrote:
> > > Hi,
> > > On Ter, 2017-02-07 at 22:32 +0100, Marek Polacek wrote:
> > > > some C++ FE changes (especially the "Fix type-dependence
> > > > and the current instantiation" changes made the compiler to
reject
> > > > invalid code
> > > > that had previously been accepted, plus invalid conversions with
'\0'
> > > > are now
> > > > rejected)
> > >
> > > Thanks for exhaustive explanation .
> > > I have this case, how we fix ?
> > > src/rtphint.cpp:342:35: error: ISO C++ forbids comparison between
> > > pointer and integer [-fpermissive]
> > > if (pSlash != '\0') {
> > >
> >
> > Someone would need to see more code than that. How is pSlash declared?
> > What is the context of the code you have quoted?
>
> Well I'm guessing it's a pointer to char and that should probably be:
>
> if (*pSlash != '\0')
Yeah, or it can be also
if (pSlash != NULL)
or
if (pSlash)
etc.
It really depends on what the code is trying to do.
Yeah, a lot of "interesting" code I looked at was trying to check for
a null pointer by comparing to '\0' or was doing char* p = '\0' to
initialize a pointer to null.
Simply changing it to (*pSlash != '\0') would cause a segfault if that
pointer can be null and the code was trying to check for that case.