boost.iterators - iterator_facade issue with aligned types.
Hi, It seems to me that boost::iterator_facade cannot cope with aligned types when the 'Reference = use_default' template argument is not a reference, which can happen if transform_iterator is used to return the result of a temporay calculation (by value of course). Inside iterator_facade.hpp struct operator_arrow_result { //... static type make(Reference x) { return implicit_cast<type>(&x); } }; Reference here is passed by value. Since Reference has alignment the compiler reports an error. The issue was resolved once i changed that code to struct operator_arrow_result { //... typedef typename mpl::if_< is_reference<Reference> , Reference , typename add_reference<Reference>::type >::type input_type; static type make(input_type x) { return implicit_cast<type>(&x); } }; I wonder about any side effects this would cause? My lousy research is based boost 1.43. That part of the code seems to be unchanged for the current trunk. Best regards, Christoph
At Wed, 19 Jan 2011 14:36:24 +0100, Christoph Heindl wrote:
It seems to me that boost::iterator_facade cannot cope with aligned types when the 'Reference = use_default' template argument is not a reference, which can happen if transform_iterator is used to return the result of a temporay calculation (by value of course).
Inside iterator_facade.hpp
struct operator_arrow_result { //... static type make(Reference x) { return implicit_cast<type>(&x); } };
Reference here is passed by value. Since Reference has alignment the compiler reports an error.
The issue was resolved once i changed that code to
struct operator_arrow_result { //... typedef typename mpl::if_< is_reference<Reference> , Reference , typename add_reference<Reference>::type >::type input_type;
static type make(input_type x) { return implicit_cast<type>(&x); } };
I wonder about any side effects this would cause? My lousy research is based boost 1.43. That part of the code seems to be unchanged for the current trunk.
I *think* that change is safe to make. Care to submit it as a patch at http://svn.boost.org/ ? Thanks! -- Dave Abrahams BoostPro Computing http://www.boostpro.com
On Wed, Jan 19, 2011 at 7:12 PM, Dave Abrahams
I *think* that change is safe to make. Care to submit it as a patch at http://svn.boost.org/ ?
Sure. It will take me a day or so, since I've modified boost 1.43.0 and did not run any boost tests. Any special tests I should run, except those for boost.iterators? Christoph
On Wed, Jan 19, 2011 at 8:39 PM, Christoph Heindl
On Wed, Jan 19, 2011 at 7:12 PM, Dave Abrahams
wrote: I *think* that change is safe to make. Care to submit it as a patch at http://svn.boost.org/ ?
Sure.
Failed to submit the patch twice. The server tells me to enable cookies once I hit "Create Ticket", but cookies are enabled. Here's my ticket content: It seems to me that boost::iterator_facade cannot cope with aligned types when the 'Reference = use_default' template argument is not a reference, which can happen if transform_iterator is used to return the result of a temporary calculation (by value of course). Patch attached. Tested against non-boost test cases. See http://thread.gmane.org/gmane.comp.lib.boost.user/65215 Best regards, Christoph
OK, thanks; I'll put it in. At Thu, 20 Jan 2011 20:46:45 +0100, Christoph Heindl wrote:
[1
] On Wed, Jan 19, 2011 at 8:39 PM, Christoph Heindl wrote: On Wed, Jan 19, 2011 at 7:12 PM, Dave Abrahams
wrote: I *think* that change is safe to make. Care to submit it as a patch at http://svn.boost.org/ ?
Sure.
Failed to submit the patch twice. The server tells me to enable cookies once I hit "Create Ticket", but cookies are enabled.
Here's my ticket content:
It seems to me that boost::iterator_facade cannot cope with aligned types when the 'Reference = use_default' template argument is not a reference, which can happen if transform_iterator is used to return the result of a temporary calculation (by value of course).
Patch attached. Tested against non-boost test cases.
See http://thread.gmane.org/gmane.comp.lib.boost.user/65215
Best regards, Christoph [2 type_with_alignment.patch
] [3
] _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
participants (2)
-
Christoph Heindl
-
Dave Abrahams