Modify

Ticket #6370 (closed Bugs: fixed)

Opened 2 years ago

Last modified 2 years ago

GCC sequence-point warning in unordered_map::iterator increment operator++

Reported by: john@… Owned by: danieljames
Milestone: Boost 1.49.0 Component: unordered
Version: Boost 1.48.0 Severity: Problem
Keywords: Cc:

Description

The following code triggers GCC -Wsequence-point warning. It is unclear whether GCC has detected a bug in boost::unordered_map, or whether this is a false positive.

#include <boost/unordered_map.hpp>
void f (){
    boost::unordered_map<int,int>::iterator i;
    ++i;
}
  • The issue appears in boost 1_48 (latest).
  • The issue does not appear in 1_47.
  • The GCC version is 4.6.2 (latest).
  • const_iterator does not trigger the issue.

The complete output is:

$ g++ -Wall -c issue.cpp 
In file included from /usr/include/boost/unordered/detail/equivalent.hpp:14:0,
                 from /usr/include/boost/unordered/unordered_map.hpp:18,
                 from /usr/include/boost/unordered_map.hpp:16,
                 from wtf.cpp:1:
/usr/include/boost/unordered/detail/table.hpp: In member function ‘boost::unordered::iterator_detail::iterator<NodePointer, Value>& boost::unordered::iterator_detail::iterator<NodePointer, Value>::operator++() [with NodePointer = boost::unordered::detail::ptr_node<std::pair<const int, int> >*, Value = std::pair<const int, int>, boost::unordered::iterator_detail::iterator<NodePointer, Value> = boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const int, int> >*, std::pair<const int, int> >]’:
wtf.cpp:4:7:   instantiated from here
/usr/include/boost/unordered/detail/table.hpp:177:13: warning: operation on ‘((boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const int, int> >*, std::pair<const int, int> >*)this)->boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const int, int> >*, std::pair<const int, int> >::node_’ may be undefined [-Wsequence-point]

Attachments

Change History

comment:1 Changed 2 years ago by danieljames

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from To Be Determined to Boost 1.49.0

Thanks for the report. This has already been fixed in [75599]. If you want to fix your copy you can download the unified diff from the bottom of the changeset page, it should apply cleanly to 1.48. It's due to a typo in boost/unordered/detail/table.hpp, probably a search and replace accident. I don't think it's an actual problem, but it is quite embarrassing!

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.