On Thu, 11 May 2017, Bruce Dubbs wrote:

modules/filter/tex.cpp:177:72: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  if (top.in_what == Parm || top.in_what == Opt || top.do_check == '\0')

The '\0' is an old way to check for a null string. It probably can be fixed with

strlen(top.do_check) == 0

or possibly

top.do_check == (char*)'\0'

I partially disagree. To me, it is unclear (at first glance) what the author actually wanted to express. The error is there for good reason!

What the code actually does is comparing a pointer to a character literal. An identical but correct way to write this would be
top.do_check == NULL

But I doubt this was the intention. It seems more likely the author wanted to compare with an empty string just as he did 5 lines above:
*top.do_check == '\0'

If there is any chance do_check was a null pointer at the point in question (what the code is currently checking for), it would have crashed 5 lines above when dereferencing it.

So I'd say the only valid interpretation is it should be
*top.do_check == '\0'
(or   strlen(top.do_check) == 0   if you like it more complicated)

while   top.do_check == (char*)'\0'
is wrong (it fixes the error too and is what the code currently says but if true would have crashed beforehand)


Uwe
--
http://lists.linuxfromscratch.org/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to