[GOLD] fix a current mainline g++ complaint
Alan Modra
amodra@gmail.com
Thu May 20 03:46:19 GMT 2021
...gold/gc.h:250:37: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: [-Werror]
250 | (*secvec).push_back(Section_id(NULL, 0));
| ^~~~~~~~~~~~~~~~~~~
...stl_pair.h:426:17: note: candidate 1: ‘constexpr std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _U1 = gold::Relobj*; _U2 = unsigned int; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_ConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = true; _T1 = gold::Relobj*; _T2 = unsigned int]’
426 | constexpr pair(const _T1& __a, const _T2& __b)
| ^~~~
...stl_pair.h:511:18: note: candidate 2: ‘constexpr std::pair<_T1, _T2>::pair(std::pair<_T1, _T2>::__null_ptr_constant, _U2&&) [with _U2 = int; typename std::enable_if<((! std::__or_<std::is_same<_U2, const _T2&>, std::is_same<_U2, _T2&> >::value) && std::_PCC<true, _T1, _T2>::_DeprConsPair<true, std::nullptr_t, _U2>()), bool>::type <anonymous> = true; _T1 = gold::Relobj*; _T2 = unsigned int]’
511 | constexpr pair(__null_ptr_constant, _U2&& __y)
| ^~~~
I don't know enough to say gcc is correct here in the warning, or
whether this should be fixed in stl_pair.h. So treat this as a heads
up.
* gc.h (gc_process_relocs): Cast NULL to Relobj* in Section_id
constructor.
diff --git a/gold/gc.h b/gold/gc.h
index 2c20b44b6ed..6ebd81f3fd0 100644
--- a/gold/gc.h
+++ b/gold/gc.h
@@ -247,7 +247,7 @@ gc_process_relocs(
if (is_ordinary)
(*secvec).push_back(Section_id(src_obj, dst_indx));
else
- (*secvec).push_back(Section_id(NULL, 0));
+ (*secvec).push_back(Section_id(reinterpret_cast<Relobj*>(NULL), 0));
// If the target of the relocation is an STT_SECTION symbol,
// make a note of that by storing -1 in the symbol vector.
if (lsym.get_st_type() == elfcpp::STT_SECTION)
@@ -329,7 +329,7 @@ gc_process_relocs(
if (is_ordinary && dst_obj != NULL)
(*secvec).push_back(Section_id(dst_obj, dst_indx));
else
- (*secvec).push_back(Section_id(NULL, 0));
+ (*secvec).push_back(Section_id(reinterpret_cast<Relobj*>(NULL), 0));
(*symvec).push_back(gsym);
(*addendvec).push_back(std::make_pair(
static_cast<long long>(symvalue),
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list