Opened 8 years ago

Last modified 8 years ago

#10789 new Bugs

unexpected behaviour with boost range join on rvalue

Reported by: Matei David <matei@…> Owned by: Neil Groves
Milestone: To Be Determined Component: range
Version: Boost 1.57.0 Severity: Problem
Keywords: Cc:

Description

I'm trying to append one element to a range, and iterate over the resulting compound range. When the rhs of the join is an lvalue, everything seems ok. However, when the rhs of the join is an rvalue, I'm seeing something unexpected.

Specifically, when such a joined range is accessed directly by a for(auto e : range) loop, or when it is saved in a variable using auto, then iterated over, the singleton in the second container is not produced correctly. If however the joined range is passed by reference (other than non-const lvalue, obviously), then iterated over, the result is correct.

Attachments (1)

example-join.cpp (2.9 KB ) - added by Matei David <matei@…> 8 years ago.

Download all attachments as: .zip

Change History (2)

by Matei David <matei@…>, 8 years ago

Attachment: example-join.cpp added

comment:1 by Matei David <matei@…>, 8 years ago

I'm using gcc-4.8.2 and clang-3.5. I'm compiling with:

[g++|clang++] -std=c++11 -Wall -Wextra -pedantic example-join.cpp -o example-join

The results I'm seeing are either "12 34", which is ok, or "12 0", which is not ok. Note that the last element is not even default constructed (which would be 99, not 0).

Note: See TracTickets for help on using tickets.