[Boost-bugs] [Boost C++ Libraries] #12595: Unexpected result when using type_erased adaptor to a transformed_range when clang optimizations are enabled

Subject: [Boost-bugs] [Boost C++ Libraries] #12595: Unexpected result when using type_erased adaptor to a transformed_range when clang optimizations are enabled
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-11-08 06:11:41


#12595: Unexpected result when using type_erased adaptor to a transformed_range
when clang optimizations are enabled
-------------------------------------------------+-------------------------
 Reporter: Alfredo Altamirano | Owner: neilgroves
  <fredy.altamirano8@…> | Status: new
     Type: Bugs | Component: range
Milestone: To Be Determined | Severity: Problem
  Version: Boost 1.61.0 |
 Keywords: |
-------------------------------------------------+-------------------------
 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.

 http://stackoverflow.com/questions/40479397/getting-unexpected-result-
 when-compiling-with-clang-
 optimization?noredirect=1#comment68203492_40479397

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12595>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC