Menu

#69 the boolean expression always return false

0.5.0
closed-invalid
nobody
None
5
2015-03-06
2014-06-10
fu zhufang
No

hello author, I find a expression that in json_reader.cpp 566 line. like this: bool badTokenType = ( token.type_ == tokenArraySeparator && token.type_ == tokenArrayEnd ); the boolean expression always return false. I think not '&&' but '||', do you thing so ?

Discussion

  • Christopher Dunn

    Seems fine to me. That token must be either tokenArraySeparator or tokenArrayEnd at that point.

     
  • Klaus Gütter

    Klaus Gütter - 2014-07-21

    Then it should be:

    bool badTokenType = ( token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd );

    ("!=" unstead of "=="), or?

     
  • Christopher Dunn

    Maybe your version is out of date. Look here:
    https://github.com/open-source-parsers/jsoncpp/blob/master/src/lib_json/json_reader.cpp#L483

    bool badTokenType =
            (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);
    

    That looks correct to me. It's "de morgan" equivalent to

    !(t == arraysep || t == end)
    
     
  • Klaus Gütter

    Klaus Gütter - 2014-07-22

    Indeed - my version is 0.5.0 which seems to be the current "official" version. And in 0.5.0 it's "==" instead of "!=".
    Which version would you recommend?

     
  • Christopher Dunn

    Use the latest from GitHub. If you need a tarball, GitHub can supply that.

     
  • Christopher Dunn

    • status: open --> closed-invalid
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.