Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid gcc parse errors #1533

wants to merge 1 commit into
base: master


Copy link

commented Jun 30, 2019

I'm using rapidjson in a larger project over here:

I recently updated to master so that I could make use of RAPIDJSON_ASSERT_THROWS which removes clang warnings when you override the rapidjson default assert behavior with a throw statement. In fact, clang compiles everything like a charm and now the project has no warnings, as of this PR: valhalla/valhalla#1864. However you'll notice that the PR is failing to build on platforms that compile using gcc.

Specifically I'm seeing the following compiler error when including rapidjson:

In file included from /home/kkreiser/sandbox/valhalla/valhalla/valhalla/baldr/rapidjson_utils.h:34:0,
                 from /home/kkreiser/sandbox/valhalla/valhalla/src/mjolnir/
/home/kkreiser/sandbox/valhalla/valhalla/third_party/rapidjson/include/rapidjson/pointer.h: In member function ‘bool rapidjson::GenericPointer<ValueType, Allocator>::operator<(const rapidjson::GenericPointer<ValueType, Allocator>&) const’:
/home/kkreiser/sandbox/valhalla/valhalla/third_party/rapidjson/include/rapidjson/pointer.h:407:59: error: the value of ‘i’ is not usable in a constant expression
                 return tokens_[i].length < rhs.tokens_[i].length;
/home/kkreiser/sandbox/valhalla/valhalla/third_party/rapidjson/include/rapidjson/pointer.h:402:21: note: ‘std::size_t i’ is not const
         for (size_t i = 0; i < tokenCount_; i++) {
/home/kkreiser/sandbox/valhalla/valhalla/third_party/rapidjson/include/rapidjson/pointer.h:407:35: error: parse error in template argument list
                 return tokens_[i].length < rhs.tokens_[i].length;

Honestly the error seems to make almost no sense to me given the actual code in pointer.h. Seems like maybe some macro-magic is going wrong somewhere or gcc has a bug. Anyway... I found that if I simply put the operands of the less than operator in parenthesis, gcc doesn't complain.

I know this is probably not the fix the project would like use in the long run, but I've been both unable to come up with a minimal example and unable to track down the error to something else. I did see various places on the internet complaining about something similar sounding: and, so I though it would be worth bringing it to your attention.


This comment has been minimized.

Copy link

commented Jun 30, 2019

CLA assistant check
All committers have signed the CLA.


This comment has been minimized.

Copy link

commented Jun 30, 2019

Coverage Status

Coverage increased (+0.003%) to 99.922% when pulling 134b453 on kevinkreiser:master into d87b698 on Tencent:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.