Skip to content

Commit 3ef5c2b

Browse files
committed
vtr_memory: add operator== for aligned_allocator
This fixes building with GCC11, which previously errored: In file included from /usr/include/c++/11.1.0/bits/stl_algobase.h:59, from /usr/include/c++/11.1.0/vector:60, from /builddir/vtr-verilog-to-routing/libs/libvtrutil/src/vtr_linear_map.h:3, from /builddir/vtr-verilog-to-routing/vpr/src/timing/PostClusterDelayCalculator.h:3, from /builddir/vtr-verilog-to-routing/vpr/src/timing/AnalysisDelayCalculator.h:4, from /builddir/vtr-verilog-to-routing/vpr/src/analysis/timing_reports.h:5, from /builddir/vtr-verilog-to-routing/vpr/src/analysis/timing_reports.cpp:1: /usr/include/c++/11.1.0/bits/stl_vector.h: In instantiation of ‘void std::vector<_Tp, _Alloc>::swap(std::vector<_Tp, _Alloc>&) [with _Tp = t_rr_node_data; _Alloc = vtr::aligned_allocator<t_rr_node_data>]’: /usr/include/c++/11.1.0/bits/allocator.h:308:28: required from ‘static bool std::__shrink_to_fit_aux<_Tp, true>::_S_do_it(_Tp&) [with _Tp = std::vector<t_rr_node_data, vtr::aligned_allocator<t_rr_node_data> >]’ /usr/include/c++/11.1.0/bits/vector.tcc:693:56: required from ‘bool std::vector<_Tp, _Alloc>::_M_shrink_to_fit() [with _Tp = t_rr_node_data; _Alloc = vtr::aligned_allocator<t_rr_node_data>]’ /usr/include/c++/11.1.0/bits/stl_vector.h:990:9: required from ‘void std::vector<_Tp, _Alloc>::shrink_to_fit() [with _Tp = t_rr_node_data; _Alloc = vtr::aligned_allocator<t_rr_node_data>]’ /builddir/vtr-verilog-to-routing/vpr/src/route/rr_graph_storage.h:442:36: required from here /usr/include/c++/11.1.0/bits/stl_vector.h:1483:9: error: no match for ‘operator==’ (operand types are ‘std::_Vector_base<t_rr_node_data, vtr::aligned_allocator<t_rr_node_data> >::_Tp_alloc_type’ {aka ‘std::allocator_traits<vtr::aligned_allocator<t_rr_node_data> >::rebind_alloc<t_rr_node_data>’} and ‘std::_Vector_base<t_rr_node_data, vtr::aligned_allocator<t_rr_node_data> >::_Tp_alloc_type’ {aka ‘std::allocator_traits<vtr::aligned_allocator<t_rr_node_data> >::rebind_alloc<t_rr_node_data>’}) 1483 | __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value | ^~~~~~~~~~~~~~~~ This is caused by gcc commit 10f51543b, which adds compile-time checking to __glibcxx_assert regardless of the _GLIBCXX_ASSERTIONS preprocessor definition. An assert in std::vector::swap that compares the two vectors' allocators was previously completely removed by the preprocessor, but now expands to a static assert. Since no equality operator is defined for aligned_allocator, any instantiation of a vector with this allocator fails to compile.
1 parent 606b079 commit 3ef5c2b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

libs/libvtrutil/src/vtr_memory.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ struct aligned_allocator {
136136
}
137137
};
138138

139+
/**
140+
* @brief compare two aligned_allocators.
141+
*
142+
* Since the allocator doesn't have any internal state, all allocators for a given type are the same.
143+
*/
144+
template<typename T>
145+
bool operator==(const aligned_allocator<T>&, const aligned_allocator<T>&) {
146+
return true;
147+
}
148+
139149
} // namespace vtr
140150

141151
#endif

0 commit comments

Comments
 (0)