Opened 10 years ago
Closed 10 years ago
#7900 closed Patches (fixed)
karma indirect_iterator returns reference to temporary
Reported by: | Owned by: | Hartmut Kaiser | |
---|---|---|---|
Milestone: | To Be Determined | Component: | spirit |
Version: | Boost Release Branch | Severity: | Problem |
Keywords: | karma indirect_iterator | Cc: |
Description
Hello,
The indirect_iterator in boost/spirit/home/karma/detail/indirect_iterator.hpp returns a reference to a temporary in at least one corner case. The compiler will issue a warning, but it's still UB.
I attached the minimal code to reproduce the behavior as well as a fix. Without the fix, it will print crap and issue a warning (on Clang and GCC).
What happens: I create a transformed_range, which uses a transform_iterator under the hood. Since the function performing the transformation returns by value, the the iterator_traits<transform_iterator>::reference type is NOT the same as iterator_traits<transform_iterator>::value_type const&, hence the return of a reference to a temporary.
My setup:
gcc version 4.7.2 clang version 3.2 boost-trunk@82516
Best,
Louis Dionne
Attachments (2)
Change History (5)
by , 10 years ago
Attachment: | indirect_iterator.diff added |
---|
comment:1 by , 10 years ago
Sorry for the mis-formatting of my setup. Should've previewed the ticket before posting!
My setup:
gcc version 4.7.2
clang version 3.2
boost-trunk@82516
comment:2 by , 10 years ago
Owner: | changed from | to
---|
comment:3 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
fix for the issue