[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 #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-16 branch has been updated by Jason Merrill
<[email protected]>:

https://gcc.gnu.org/g:2e1c4ce1640aa26f391e7aaf842500d98b9bc483

commit r16-9417-g2e1c4ce1640aa26f391e7aaf842500d98b9bc483
Author: Jason Merrill <[email protected]>
Date:   Mon Jul 27 13:25:33 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.

    (cherry picked from commit 0e429acc24a2305c77da1229c456788e50edcae9)
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.