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

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

https://gcc.gnu.org/g:059231fb8a42eaeac8880c5d207249b46757767c

commit r17-4537-g059231fb8a42eaeac8880c5d207249b46757767c
Author: Léo Hardt <[email protected]>
Date:   Mon Sep 21 12:41:35 2026 -0600

    [PATCH][PR preprocessor/121508] fix(libcpp): Don't ICE parsing
__has_include outside directive.

    fix(libcpp): Don't ICE parsing __has_include outside directive.
    cc: libcpp maintainers.

    Fixes an ICE wherein 'glue_header_name' is called outside
    parsing a preprocessor directive, causing an entire file to
    be read and presumed to be a header name. Then, on the next
    read (the closing '>' or ')'), the parser ICEs since the input
    has already come to an end.

    Affects __has_include and __has_embed when used outside directives.
    Minimal reproducible crash has two tokens (both gcc and g++):

      __has_include<

    Given glue_header_name was written for usage inside preprocessor
    parsing, we could either change it or not call it in case of errors.
    I opted to bail out early on an error case, since there is no chance
    it could influence valid code parsing.

    See more on https://gcc.gnu.org/PR121508.

            PR preprocessor/121508
            PR preprocessor/123339

    libcpp/ChangeLog:

            * macro.cc (builtin_has_include_1): Bail early if
            not on a preprocessor directive.

    Signed-off-by: Léo Hardt <[email protected]>

Reply via email to