BOOST_FOREACH infinite loop issue
Hi, I have a problem with BOOST_FOREACH never ending under specific conditions described here: http://stackoverflow.com/questions/2881491/need-help-with-boost-foreach-comp... Could anyone help me understand what's going on? Best regards, Jacek Ławrynowicz
AMDG yabcok wrote:
I have a problem with BOOST_FOREACH never ending under specific conditions described here: http://stackoverflow.com/questions/2881491/need-help-with-boost-foreach-comp...
Could anyone help me understand what's going on?
Can you reduce it to something I can actually compile and run myself? The code you posted is incomplete, I don't see an obvious explanation, and bugs like this are often nasty to trace. In Christ, Steven Watanabe
Sure. Here: http://geneviz.googlecode.com/files/ugly.zip Regards, Jacek On Fri, May 21, 2010 at 6:48 PM, Steven Watanabe <watanabesj@gmail.com> wrote:
AMDG
yabcok wrote:
I have a problem with BOOST_FOREACH never ending under specific conditions described here:
http://stackoverflow.com/questions/2881491/need-help-with-boost-foreach-comp...
Could anyone help me understand what's going on?
Can you reduce it to something I can actually compile and run myself? The code you posted is incomplete, I don't see an obvious explanation, and bugs like this are often nasty to trace.
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I simplified the code even more. Get it here: http://yabcok.nazwa.pl/ugly3.zip In release build (VC2008 SP1) there's an infinite BOOST_FOREACH loop, debug builds and other compilers (gcc, vc10) are OK. My skills are insufficient to root cause this problem. Could anyone help me out? Regards, Jacek On Sat, May 29, 2010 at 9:22 AM, yabcok <yabcok@gmail.com> wrote:
Sure. Here: http://geneviz.googlecode.com/files/ugly.zip
Regards, Jacek
On Fri, May 21, 2010 at 6:48 PM, Steven Watanabe <watanabesj@gmail.com> wrote:
AMDG
yabcok wrote:
I have a problem with BOOST_FOREACH never ending under specific conditions described here:
http://stackoverflow.com/questions/2881491/need-help-with-boost-foreach-comp...
Could anyone help me understand what's going on?
Can you reduce it to something I can actually compile and run myself? The code you posted is incomplete, I don't see an obvious explanation, and bugs like this are often nasty to trace.
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Thu, Jun 10, 2010 at 9:02 PM, yabcok <yabcok@gmail.com> wrote:
I simplified the code even more. Get it here: http://yabcok.nazwa.pl/ugly3.zip In release build (VC2008 SP1) there's an infinite BOOST_FOREACH loop, debug builds and other compilers (gcc, vc10) are OK.
My skills are insufficient to root cause this problem. Could anyone help me out?
Your iterator increment function in vector_elements_list.h is broken. In the case you attached the iterator starts with a handle of zero. The first increment will cause handle to be incremented to one. Subsequent increment operations have no effect.
Regards, Jacek
Regards, Neil Groves
I'm afraid you are wrong. Subsequent handle values would be 0, 1, INVALID_ELEMENT_HANDLE. Please, compare this program behavior in release and debug builds, to see the real problem (infinite lopp at the last BOOST_FOREACH). Regards, Jacek On Thu, Jun 10, 2010 at 11:30 PM, Neil Groves <neil@grovescomputing.com> wrote:
On Thu, Jun 10, 2010 at 9:02 PM, yabcok <yabcok@gmail.com> wrote:
I simplified the code even more. Get it here: http://yabcok.nazwa.pl/ugly3.zip In release build (VC2008 SP1) there's an infinite BOOST_FOREACH loop, debug builds and other compilers (gcc, vc10) are OK.
My skills are insufficient to root cause this problem. Could anyone help me out?
Your iterator increment function in vector_elements_list.h is broken.
In the case you attached the iterator starts with a handle of zero. The first increment will cause handle to be incremented to one. Subsequent increment operations have no effect.
Regards, Jacek
Regards, Neil Groves
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Fri, Jun 11, 2010 at 4:17 PM, yabcok <yabcok@gmail.com> wrote:
I'm afraid you are wrong. Subsequent handle values would be 0, 1, INVALID_ELEMENT_HANDLE.
Yes, you are correct. The sequence is always 0, 1, INVALID_ELEMENT_HANDLE.
Please, compare this program behavior in release and debug builds, to see the real problem (infinite lopp at the last BOOST_FOREACH).
I have looked into this problem, and have tracked it down to an interaction between code optimization and the use of std::pair with BOOST_FOREACH. The problem can be worked around by replacing std::pair<Iterator, Iterator> with boost::iterator_range<Iterator> which to my mind is a neater solution anyhow. Hopefully this information will be of some use to you, and I shall continue to investigate the problem with std::pair.
Regards, Jacek
Sorry for my earlier mistake. Regards, Neil Groves
participants (3)
-
Neil Groves
-
Steven Watanabe
-
yabcok