[Boost-bugs] [Boost C++ Libraries] #10430: joined_range generates invalid range with recent gcc versions with optimization enabled

Subject: [Boost-bugs] [Boost C++ Libraries] #10430: joined_range generates invalid range with recent gcc versions with optimization enabled
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-08-30 19:40:42


#10430: joined_range generates invalid range with recent gcc versions with
optimization enabled
---------------------------------------+------------------------
 Reporter: Oliver Seiler <oseiler@…> | Owner: neilgroves
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: range
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: |
---------------------------------------+------------------------
 This came up in tracking down unit-test failures when trying to build a
 project with newer compiler versions with C++11 enabled. The unit-test in
 question was compiled with multiple compiler versions:
 * gcc 4.3.4 (without C++11 enabled): working at all optimization levels
 * gcc 4.7.2 (with C++11 enabled): works without optimizations, failed with
 -O1 or higher
 * gcc 4.8.4 (with C++11 enabled): works without optimizations, failed with
 -O1 or higher
 * clang 3.5.0 (recent build, with C++11 enabled): works at all
 optimization levels

 The failure was tracked down to a use of boost::range::joined_range (Boost
 1.55.0), effectively declared as:

 {{{
 boost::range::joined_range<boost::iterator_range<std::vector<char>::iterator,
 boost::iterator_range<const char*>>
 }}}

 In this form, the joined_range created from two valid ranges winds up
 "somewhere else" when the higher optimization level. I've attached a test
 case that demonstrates the problem. Compiled with:

 {{{
 g++ -std=c++11 -o join_bug join_bug.cpp
 }}}

 works (printing out the expected ASCII values of the joined ranges).
 Compiled with:

 {{{
 g++ -O1 -std=c++11 -o join_bug join_bug.cpp
 }}}

 fails (printing out zero's in my test, though the correct number of them).
 This test was run with the same compiler versions as above, on both Boost
 1.54.0 and Boost 1.55.0, as well as gcc 4.8.2 and clang 3.4 (both for
 Ubuntu 14.04), with a slightly modified non-C++11 version for the gcc
 4.3.4 compiler, all with the same successes/failures.

 The problem goes away in all tests if the joined_range is declared like so
 (changing from std::vector<char>::iterator to
 std::vector<char>::const_iterator):

 {{{
 boost::range::joined_range<boost::iterator_range<std::vector<char>::const_iterator,
 boost::iterator_range<const char*>>
 }}}

 I realize this might be a gcc bug, rather than a Boost bug, but I haven't
 seen this reported elsewhere and would like to get the behaviour tracked
 since I'm only seeing problems in relation to joined_range...

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10430>
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:16 UTC