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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

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

commit r15-7360-ga64d9c96d8ebb0ba2a52daec85779b1a99c2f7fd
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Tue Feb 4 21:16:57 2025 +0100

    c++: Fix ICE with #embed/RAW_DATA_CST after list conversion [PR118671]

    The following testcases ICE with RAW_DATA_CSTs (so the first one since
    introduction of #embed C++ optimizations and the latter since optimization
    of large sequences of comma separated literals).
    I've missed the fact that implicit_conversion can embed the exact
expression
    passed to it into stuff pointed out by conversion * (e.g. for user
    conversions in sub->cand->args).
    So, it isn't enough in convert_like_internal to pass the right INTEGER_CST
    for each element of the RAW_DATA_CST because the whole RAW_DATA_CST might
be
    in sub->cand->args etc.
    Either I'd need to chase for wherever the RAW_DATA_CST is found and update
    those for each element processed, or, as implemented in the following
patch,
    build_list_conv detects the easy optimizable case where
    convert_like_internal can be kept as the whole RAW_DATA_CST with changed
    type and possibly narrowing diagnostics, and otherwise instead of having
    a single subconversion it has RAW_DATA_CST separate subconversions.
    Instead of trying to reallocate the subconvs array when we detect that
case,
    the patch instead uses an artificial ck_list inside of the u.list array
    to hold the individual subconversions.
    Seems the only places where u.list is used are build_list_conv and
    convert_like_internal.

    2025-02-04  Jakub Jelinek  <ja...@redhat.com>

            PR c++/118671
            * call.cc (build_list_conv): For RAW_DATA_CST, call
            implicit_conversion with INTEGER_CST representing first byte
instead
            of the whole RAW_DATA_CST.  If it is an optimizable trivial
            conversion, just save that to subconvs, otherwise allocate an
            artificial ck_list for all the RAW_DATA_CST bytes and create
            subsubconv for each of them.
            (convert_like_internal): For ck_list with RAW_DATA_CST, instead of
            doing all the checks for optimizable conversion just check kind and
            assert everything else, otherwise use subsubconversions instead of
            the subconversion for each element.

            * g++.dg/cpp/embed-25.C: New test.
            * g++.dg/cpp0x/pr118671.C: New test.

Reply via email to