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

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

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

commit r16-8475-gb34f04aea55821c2fbd4af452120718af15b24f5
Author: Jakub Jelinek <[email protected]>
Date:   Sun Apr 5 18:06:34 2026 +0200

    c++: Error recovery for fuzzed <meta> [PR124689]

    I knew this was coming, but hoped it would come later ;)
    Basically, when one preprocesses <meta> + some reflection code and
    attempts to fuzz it, we can ICE in various ways as we expect a sane
    <meta>.  In various places we've already tried to be defensive, error
    out e.g. when we don't find the members we are looking for in <meta>
    classes etc., plus when adding metafns.gperf I've added to the details
    about each metafn the types of arguments and return type (which was
    only partially used to evaluate e.g. the arguments in different ways
    and prepare for the eval_* handlers, but checking of the types
    wasn't actually done.

    This patch introduces some limited checking of the return type and
    argument types to make sure they are sane.  Plus I've noticed the
    can_substitute marking said incorrectly it returns info when it returns
    bool.

    The reflection_range/input_range arguments aren't checked, because they
    can be all kinds of things and get_range_elts already does a lot of
    checking.  Similarly METAFN_KIND_ARG_TEMPLATE_PARM*, those aren't even
    argument types, just a hack to tell the code that it needs to supply
    the template parameter to the eval_* handlers.

    2026-04-05  Jakub Jelinek  <[email protected]>

            PR c++/124689
            * metafns.gperf (enum metafn_kind): Add
            METAFN_KIND_BOOL_INFO_REFLECTION_RANGE.
            (can_substitute): Use METAFN_KIND_BOOL_INFO_REFLECTION_RANGE
            instead of METAFN_KIND_INFO_INFO_REFLECTION_RANGE.
            (METAFN_KIND_ARG): Add MINFO argument.
            (METAFN_KIND_RET): Define.
            * reflect.cc (is_std_meta_class): New function.
            (get_info): Add LOC argument, diagnose invalid argument type
instead
            of failing assertion.
            (check_metafn_arg_type): New function.
            (check_metafn_return_type): New function.
            (process_metafunction): Diagnose clearly invalid return
            or argument types.  Use rettype variable instead of TREE_TYPE
(call).
            * metafns.h: Regenerate.

            * g++.dg/reflect/pr124689.C: New test.

    Reviewed-by: Jason Merrill <[email protected]>

Reply via email to