public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [GOLD] fix a current mainline g++ complaint
@ 2021-05-20  3:46 Alan Modra
  2021-05-20 23:26 ` Cary Coutant
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2021-05-20  3:46 UTC (permalink / raw)
  To: binutils

...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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [GOLD] fix a current mainline g++ complaint
  2021-05-20  3:46 [GOLD] fix a current mainline g++ complaint Alan Modra
@ 2021-05-20 23:26 ` Cary Coutant
  2021-05-21  2:19   ` Alan Modra
  0 siblings, 1 reply; 5+ messages in thread
From: Cary Coutant @ 2021-05-20 23:26 UTC (permalink / raw)
  To: Alan Modra; +Cc: Binutils

> 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.

Please add PR gold/27815 to the ChangeLog entry. I was planning on
fixing this by using nullptr instead of NULL, which would have limited
our build environment to GCC 4.6 and later. I just haven't had a
chance to build a GCC 12 for testing yet.

-cary

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [GOLD] fix a current mainline g++ complaint
  2021-05-20 23:26 ` Cary Coutant
@ 2021-05-21  2:19   ` Alan Modra
  2021-05-21 21:57     ` Cary Coutant
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2021-05-21  2:19 UTC (permalink / raw)
  To: Cary Coutant; +Cc: Binutils

On Thu, May 20, 2021 at 04:26:19PM -0700, Cary Coutant wrote:
> > 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.
> 
> Please add PR gold/27815 to the ChangeLog entry. I was planning on
> fixing this by using nullptr instead of NULL, which would have limited
> our build environment to GCC 4.6 and later. I just haven't had a
> chance to build a GCC 12 for testing yet.

Using nullptr succeeds with gcc-12.  I'm happy to make that change if
you'd prefer it that way.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [GOLD] fix a current mainline g++ complaint
  2021-05-21  2:19   ` Alan Modra
@ 2021-05-21 21:57     ` Cary Coutant
  2021-05-25 19:01       ` Cary Coutant
  0 siblings, 1 reply; 5+ messages in thread
From: Cary Coutant @ 2021-05-21 21:57 UTC (permalink / raw)
  To: Alan Modra; +Cc: Binutils

> > >         * gc.h (gc_process_relocs): Cast NULL to Relobj* in Section_id
> > >         constructor.
> >
> > Please add PR gold/27815 to the ChangeLog entry. I was planning on
> > fixing this by using nullptr instead of NULL, which would have limited
> > our build environment to GCC 4.6 and later. I just haven't had a
> > chance to build a GCC 12 for testing yet.
>
> Using nullptr succeeds with gcc-12.  I'm happy to make that change if
> you'd prefer it that way.

Sure. Thanks for checking.

-cary

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [GOLD] fix a current mainline g++ complaint
  2021-05-21 21:57     ` Cary Coutant
@ 2021-05-25 19:01       ` Cary Coutant
  0 siblings, 0 replies; 5+ messages in thread
From: Cary Coutant @ 2021-05-25 19:01 UTC (permalink / raw)
  To: Alan Modra; +Cc: Binutils

> > > >         * gc.h (gc_process_relocs): Cast NULL to Relobj* in Section_id
> > > >         constructor.
> > >
> > > Please add PR gold/27815 to the ChangeLog entry. I was planning on
> > > fixing this by using nullptr instead of NULL, which would have limited
> > > our build environment to GCC 4.6 and later. I just haven't had a
> > > chance to build a GCC 12 for testing yet.
> >
> > Using nullptr succeeds with gcc-12.  I'm happy to make that change if
> > you'd prefer it that way.
>
> Sure. Thanks for checking.

After learning that it only works with the --std=g++0x option for GCC
4.6, I agree with your assessment that it's not worth it. Thanks!

-cary

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-25 19:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-20  3:46 [GOLD] fix a current mainline g++ complaint Alan Modra
2021-05-20 23:26 ` Cary Coutant
2021-05-21  2:19   ` Alan Modra
2021-05-21 21:57     ` Cary Coutant
2021-05-25 19:01       ` Cary Coutant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).