https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78859
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Martin Liška from comment #4) > (In reply to Jakub Jelinek from comment #3) > > (In reply to Martin Liška from comment #0) > > > There are 2 (so far) errors reported: > > > > > > 1) gengtype.c: > > > > > > ../../gcc/gengtype.c: In function ‘const char* > > > get_file_srcdir_relative_path(const input_file*)’: > > > ../../gcc/gengtype.c:1760:14: error: argument 1 null where non-null > > > expected > > > [-Werror=nonnull] > > > if (strlen (f) > srcdir_len > > > ~~~~~~~^~~ > > > > > > This is real bug, following patch fixes that: > > > > Only iff get_file_srcdir_relative_path is ever called with NULL inpf. If > > not, it is a false positive. As strlen would crash if it is called with > > NULL and it has not been reported yet, it clearly is not. > > So with the following patch (and -disable-werror) the profiledbootstrap > finishes: > > @@ -75,9 +75,8 @@ const char *get_file_srcdir_relative_path (const > input_file *inpf); > static inline const char* > get_input_file_name (const input_file *inpf) > { > - if (inpf) > - return inpf->inpname; > - return NULL; > + gcc_assert (inpf); > + return inpf->inpname; > } > > Thus, it's regression. In gengtype.c, it seems the reason for the NULL pointer checks is just a particular, too cautious, programming style. gen_input_file_name can return NULL only if inpf is NULL, which can be NULL if input_file_by_name returns NULL, which happens if it is called with NULL argument, which likely never happens. The question, is -Wnonnull something that should force people to change their (sometimes weird, sure) programming styles, just to get rid of the warning? I believe input_file_by_name is never called with NULL, because: epos.file = input_file_by_name (listname); (this is after successful fopen (listname, "r")) if (line == 0) break; ... input_file *inpf = input_file_by_name (line); should be fine, if (optind >= argc) fatal ("no source files given in plugin mode"); nb_plugin_files = argc - optind; plugin_files = XNEWVEC (input_file*, nb_plugin_files); for (i = 0; i < (int) nb_plugin_files; i++) { char *name = argv[i + optind]; plugin_files[i] = input_file_by_name (name); } args before argc should also not contain NULL this_file = input_file_by_name (__FILE__); system_h_file = input_file_by_name ("system.h"); these two aren't NULL either, and then there are some uses in gengtype-state.c, likely the state file would need to be corrupted to get NULL.