Commit 823a28c3 authored by Joe Loser's avatar Joe Loser Committed by Facebook Github Bot

Add assert in Range::size() (#1155)

Summary:
- Prior to commit 8cb615a2
  (Differential Revision: D3394612), `Range:size()` had an assert checking
  that the beginning iterator of the range is less than or equal to the end
  iterator. Unfortunately, due to GCC bug 71448, the `assert` was not allowed
  if we wanted `size()` to remain a `constexpr` function.
- This bug is no longer an issue with our current supported versions of GCC.
  As such, add the assert back in.
Pull Request resolved: https://github.com/facebook/folly/pull/1155

Reviewed By: ericniebler

Differential Revision: D15641627

Pulled By: yfeldblum

fbshipit-source-id: 0677053c18fa55aaa4727947c241f0675362861b
parent 0a36d34f
......@@ -419,12 +419,9 @@ class Range {
}
constexpr size_type size() const {
// It would be nice to assert(b_ <= e_) here. This can be achieved even
// in a C++11 compatible constexpr function:
// http://ericniebler.com/2014/09/27/assert-and-constexpr-in-cxx11/
// Unfortunately current gcc versions have a bug causing it to reject
// this check in a constexpr function:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71448
#if __clang__ || !__GNUC__ || __GNUC__ >= 7
assert(b_ <= e_);
#endif
return size_type(e_ - b_);
}
constexpr size_type walk_size() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment