https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90998

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Jason Merrill
<ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:f52ec6bc163af837cd13e234b7c2eab6bc456e12

commit r8-10081-gf52ec6bc163af837cd13e234b7c2eab6bc456e12
Author: Marek Polacek <pola...@redhat.com>
Date:   Wed Feb 26 00:33:52 2020 -0500

    PR c++/90998 - ICE with copy elision in init by ctor and -Wconversion.

    After r269667 which introduced joust_maybe_elide_copy, in C++17 we can
elide
    a constructor if it uses a conversion function that returns a prvalue, and
    use the conversion function in its stead.

    This eliding means that if we have a candidate that previously didn't have
    ->second_conv, it can have it after the elision.  This confused the
    -Wconversion warning because it was assuming that if cand1->second_conv is
    non-null, so is cand2->second_conv.  Here cand1->second_conv was non-null
    but cand2->second_conv remained null, so it crashed in compare_ics.

    I checked with clang that both compilers call A::operator B() in C++17 and
    B::B(A const &) otherwise.

    gcc/cp/ChangeLog
    2020-02-26  Marek Polacek  <pola...@redhat.com>

        PR c++/90998 - ICE with copy elision in init by ctor and -Wconversion.
        * call.c (joust): Don't attempt to warn if ->second_conv is null.

    gcc/testsuite/ChangeLog
    2020-02-26  Marek Polacek  <pola...@redhat.com>

        PR c++/90998 - ICE with copy elision in init by ctor and -Wconversion.
        * g++.dg/cpp0x/overload-conv-4.C: New test.

Reply via email to