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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Tue Oct 29 21:06:21 2019
New Revision: 277593

URL: https://gcc.gnu.org/viewcvs?rev=277593&root=gcc&view=rev
Log:
        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.

        * call.c (joust): Don't attempt to warn if ->second_conv is null.

        * g++.dg/cpp0x/overload-conv-4.C: New test.


Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/overload-conv-4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/testsuite/ChangeLog

Reply via email to