Opened 6 years ago

Closed 6 years ago

#6370 closed Bugs (fixed)

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

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


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;
  • 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 (0)

Change History (1)

comment:1 Changed 6 years ago by Daniel James

Milestone: To Be DeterminedBoost 1.49.0
Resolution: fixed
Status: newclosed

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!

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Daniel James.
The resolution will be deleted.

Add Comment

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

Note: See TracTickets for help on using tickets.