Opened 6 years ago
#12595 new Bugs
Unexpected result when using type_erased adaptor to a transformed_range when clang optimizations are enabled
Reported by: | Owned by: | Neil Groves | |
---|---|---|---|
Milestone: | To Be Determined | Component: | range |
Version: | Boost 1.61.0 | Severity: | Problem |
Keywords: | Cc: |
Description
If clang optimizations -O1 are enabled, when using type_erased adapter on a transformed_range, the range will yield wrong values.
For example:
int addOne(int b) {
return b + 1;
}
int main() {
std::vector<int> nums{ 1, 2, 3 }; auto result = nums | boost::adaptor::transformed(addOne) | boost::adaptor::type_erased<int, boost::forward_traversal_tag>();
}
When printing result, it yielded { 1, 1, 1 } instead of { 2, 3, 4 } when compiling with -O1. It worked as expected with no optimization flags. I am compiling the code with clang++. The version of clang is Apple LLVM version 8.0.0 (clang-800.0.38). And I am using c++11.
C++ code reproducing the code.