public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/104471] New: ICE with -nostdinc: NULL directory in find_file
@ 2022-02-09 18:28 gscfq@t-online.de
  2022-12-09 14:58 ` [Bug preprocessor/104471] " pinskia at gcc dot gnu.org
  2022-12-09 15:06 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: gscfq@t-online.de @ 2022-02-09 18:28 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104471
           Summary: ICE with -nostdinc: NULL directory in find_file
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Affects versions down to at least r5 :
(related to pr80753 and pr80755)


$ cat z1.c
#if __has_include (<stdlib.h>)
#endif


$ gcc-12-20220206 -c z1.c -nostdinc
z1.c:1:20: error: no include path in which to search for stdlib.h
    1 | #if __has_include (<stdlib.h>)
      |                    ^~~~~~~~~~
cc1: internal compiler error: NULL directory in find_file
0x7c8de2 c_cpp_diagnostic(cpp_reader*, cpp_diagnostic_level,
cpp_warning_reason, rich_location*, char const*, __va_list_tag (*) [1])
        ../../gcc/c-family/c-common.cc:6670
0x1e12599 cpp_error_at(cpp_reader*, cpp_diagnostic_level, unsigned int, char
const*, ...)
        ../../libcpp/errors.cc:302
0x1e17833 _cpp_find_file
        ../../libcpp/files.cc:516
0x1e18eba _cpp_has_header
        ../../libcpp/files.cc:2149
0x1e284f7 builtin_has_include
        ../../libcpp/macro.cc:429
0x1e284f7 _cpp_builtin_macro_text
        ../../libcpp/macro.cc:677
0x1e28769 builtin_macro
        ../../libcpp/macro.cc:762
0x1e25e73 enter_macro_context
        ../../libcpp/macro.cc:1588
0x1e27b60 cpp_get_token_1
        ../../libcpp/macro.cc:3018
0x1e149a4 _cpp_parse_expr
        ../../libcpp/expr.cc:1334
0x1e0eb43 do_if
        ../../libcpp/directives.cc:2060
0x1e10450 _cpp_handle_directive
        ../../libcpp/directives.cc:557
0x1e20c88 _cpp_lex_token
        ../../libcpp/lex.cc:3410
0x1e279ff cpp_get_token_1
        ../../libcpp/macro.cc:2930
0x7e553d c_lex_with_flags(tree_node**, unsigned int*, unsigned char*, int)
        ../../gcc/c-family/c-lex.cc:483
0x74bb81 c_lex_one_token
        ../../gcc/c/c-parser.cc:279
0x788454 c_parser_peek_token(c_parser*)
        ../../gcc/c/c-parser.cc:483
0x788454 c_parse_file()
        ../../gcc/c/c-parser.cc:23317
0x7f7812 c_common_parse_file()
        ../../gcc/c-family/c-opts.cc:1238

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug preprocessor/104471] ICE with -nostdinc: NULL directory in find_file
  2022-02-09 18:28 [Bug c/104471] New: ICE with -nostdinc: NULL directory in find_file gscfq@t-online.de
@ 2022-12-09 14:58 ` pinskia at gcc dot gnu.org
  2022-12-09 15:06 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-09 14:58 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-12-09

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug preprocessor/104471] ICE with -nostdinc: NULL directory in find_file
  2022-02-09 18:28 [Bug c/104471] New: ICE with -nostdinc: NULL directory in find_file gscfq@t-online.de
  2022-12-09 14:58 ` [Bug preprocessor/104471] " pinskia at gcc dot gnu.org
@ 2022-12-09 15:06 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-09 15:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This patch should fix the issue (I might get to it in a few weeks though):
diff --git a/libcpp/files.cc b/libcpp/files.cc
index a18b1caf48d..eb90fa4f65a 100644
--- a/libcpp/files.cc
+++ b/libcpp/files.cc
@@ -177,7 +177,7 @@ static bool read_file_guts (cpp_reader *pfile, _cpp_file
*file,
 static bool read_file (cpp_reader *pfile, _cpp_file *file,
                       location_t loc);
 static struct cpp_dir *search_path_head (cpp_reader *, const char *fname,
-                                int angle_brackets, enum include_type);
+                                int angle_brackets, enum include_type, bool =
true);
 static const char *dir_name_of_file (_cpp_file *file);
 static void open_file_failed (cpp_reader *pfile, _cpp_file *file, int,
                              location_t);
@@ -1026,7 +1026,7 @@ _cpp_mark_file_once_only (cpp_reader *pfile, _cpp_file
*file)
    nothing left in the path, returns NULL.  */
 static struct cpp_dir *
 search_path_head (cpp_reader *pfile, const char *fname, int angle_brackets,
-                 enum include_type type)
+                 enum include_type type, bool canerror)
 {
   cpp_dir *dir;
   _cpp_file *file;
@@ -1055,7 +1055,7 @@ search_path_head (cpp_reader *pfile, const char *fname,
int angle_brackets,
     return make_cpp_dir (pfile, dir_name_of_file (file),
                         pfile->buffer ? pfile->buffer->sysp : 0);

-  if (dir == NULL)
+  if (canerror && dir == NULL)
     cpp_error (pfile, CPP_DL_ERROR,
               "no include path in which to search for %s", fname);

@@ -2144,7 +2144,9 @@ bool
 _cpp_has_header (cpp_reader *pfile, const char *fname, int angle_brackets,
                 enum include_type type)
 {
-  cpp_dir *start_dir = search_path_head (pfile, fname, angle_brackets, type);
+  cpp_dir *start_dir = search_path_head (pfile, fname, angle_brackets, type,
false);
+  if (!start_dir)
+    return false;
   _cpp_file *file = _cpp_find_file (pfile, fname, start_dir, angle_brackets,
                                    _cpp_FFK_HAS_INCLUDE, 0);
   return file->err_no != ENOENT;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-09 15:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 18:28 [Bug c/104471] New: ICE with -nostdinc: NULL directory in find_file gscfq@t-online.de
2022-12-09 14:58 ` [Bug preprocessor/104471] " pinskia at gcc dot gnu.org
2022-12-09 15:06 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).