On Wed, Jun 12, 2024 at 1:32 PM Jason Merrill <ja...@redhat.com> wrote: > > Tested x86_64-pc-linux-gnu, applying to trunk. > > -- 8< -- > > A sample implementation of module std was breaking because the exports > included 'using std::operator&' twice. Since Nathaniel's r15-964 for > PR114867, the first using added an extra instance of each function that was > revealed/exported by that using, resulting in duplicates for > lookup_maybe_add to dedup. But if the duplicate is the first thing in the > list, lookup_add doesn't make an OVERLOAD, so trying to set OVL_USING_P > crashes. Fixed by using ovl_make in the case where we want to set the flag.
Note this was recorded as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115445 which I closed as fixed already. Thanks, Andrew > > gcc/cp/ChangeLog: > > * tree.cc (lookup_maybe_add): Use ovl_make when setting OVL_USING_P. > > gcc/testsuite/ChangeLog: > > * g++.dg/modules/using-21_a.C: New test. > --- > gcc/cp/tree.cc | 8 ++++++-- > gcc/testsuite/g++.dg/modules/using-21_a.C | 11 +++++++++++ > 2 files changed, 17 insertions(+), 2 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/modules/using-21_a.C > > diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc > index d2a8f79ffab..28648c14c6d 100644 > --- a/gcc/cp/tree.cc > +++ b/gcc/cp/tree.cc > @@ -2526,11 +2526,15 @@ lookup_maybe_add (tree fns, tree lookup, bool > deduping) > predecessors onto the lookup. */ > for (; fns != probe; fns = OVL_CHAIN (fns)) > { > - lookup = lookup_add (OVL_FUNCTION (fns), lookup); > /* Propagate OVL_USING, but OVL_HIDDEN & > OVL_DEDUP_P don't matter. */ > if (OVL_USING_P (fns)) > - OVL_USING_P (lookup) = true; > + { > + lookup = ovl_make (OVL_FUNCTION (fns), lookup); > + OVL_USING_P (lookup) = true; > + } > + else > + lookup = lookup_add (OVL_FUNCTION (fns), lookup); > } > > /* And now skip this function. */ > diff --git a/gcc/testsuite/g++.dg/modules/using-21_a.C > b/gcc/testsuite/g++.dg/modules/using-21_a.C > new file mode 100644 > index 00000000000..ce6e3f920f1 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/modules/using-21_a.C > @@ -0,0 +1,11 @@ > +// { dg-additional-options "-fmodules-ts -Wno-global-module" } > + > +module; > +namespace foo { > + void baz(); > +} > +export module foo; > +namespace foo { > + export using foo::baz; > + export using foo::baz; > +} > > base-commit: 7bf072e87a03c9eaff9b7a1ac182537b70f0ba8e > prerequisite-patch-id: 6c196fa553aea243ce21f45cd2ddf3daaa840921 > -- > 2.44.0 >