[Bug c++/126310] [16/17 regression] Miscompile due to erroneous value range propagation since r16-5887

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126310

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <[email protected]>:

https://gcc.gnu.org/g:0e429acc24a2305c77da1229c456788e50edcae9

commit r17-2722-g0e429acc24a2305c77da1229c456788e50edcae9
Author: Jason Merrill <[email protected]>
Date:   Sun Jul 26 12:44:22 2026 -0400

    c++: vrp and pmf conversion [PR126310]

    Here when trying to convert to EncodeFnTy, aka void (sub::*)(int&&), we
were
    instead converting to void (sub::*)(ValuePart&&), and the optimization
added
    by r16-5887 got confused by the values in the array initializer having
    different RECORD_TYPEs (with different FIELD_DECLs) from the type of the
    array.

    So let's correct the conversion to actually end with the requested type.

            PR c++/126310

    gcc/cp/ChangeLog:

            * call.cc (standard_conversion): Don't build a mixed METHOD_TYPE if
            it isn't needed.

    gcc/testsuite/ChangeLog:

            * g++.dg/opt/pmf2.C: New test.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.