Opened 13 years ago
Last modified 13 years ago
#3044 new Bugs
mpl::aux_::iter_fold_if_impl allows deref l_end
Reported by: | Owned by: | Aleksey Gurtovoy | |
---|---|---|---|
Milestone: | Boost 1.40.0 | Component: | mpl |
Version: | Boost 1.38.0 | Severity: | Problem |
Keywords: | Cc: |
Description
The mpl::aux_::iter_fold_if_impl template:
https://svn.boost.org/trac/boost/browser/trunk/boost/mpl/aux_
/iter_fold_if_impl.hpp
allows deref'ing of an end iterator. The problem is most easily shown with list because deref<l_end> is not possible. Apparently, deref of an end iterator from other sequences (e.g. vector or range_c) allow deref of an end iterator.
The attached:
iter_fold_if_bkprotect.zip
illustrates the problem. The attached:
iter_fold_if_bkprotect2.zip
illustrates the cause. The attached:
while.cpp
illustrates a solution. However, the while.cpp suffers from the template instantiation depth problem described here:
http://www.mywikinet.com/mpl/paper
/mpl_paper.html#sequences.unrolling
More (*maybe* helpful) details can be found at the following boost ml thread:
Attachments (6)
Change History (9)
by , 13 years ago
Attachment: | iter_fold_if_bkprotect.zip added |
---|
comment:1 by , 13 years ago
Component: | None → mpl |
---|---|
Owner: | set to |
comment:2 by , 13 years ago
Patch attached. The reverse predicate doesn't add any significant functionality, and complicates the implementation, so I removed it entirely. Since iter_fold_if with a reverse operation doesn't work currently, this shouldn't break existing code.
by , 13 years ago
Attachment: | iter_fold_if.patch added |
---|
by , 13 years ago
Attachment: | while_recur.cpp added |
---|
while.cpp replacement: while_recur (no unroll) while_unroll_recur(does unrolling)
by , 13 years ago
Attachment: | while_recur.2.cpp added |
---|
while.cpp replacement: while_recur (no unroll) while_unroll_recur(does unrolling)
comment:3 by , 13 years ago
Please ignore attachment, while_recur.2.cpp. It's just an accidental copy of while_recur.cpp.
While_recur.cpp is essentially the while.cpp attachment with template, while_recur, as a renamed while_ of the while.cpp attachment. ALso while_recur.cpp has the while_unroll_recur template which is an "unrolled" (to lessen the template instantiation depth problem mentioned in comments) version of while_recur. The macro, USE_WHILE_UNROLL, decides whether while_recur or while_unroll_recur is used.
shows bug