https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99738
Bug ID: 99738 Summary: RFE: analyzer should complain about unchecked FILE * Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: dmalcolm at gcc dot gnu.org Target Milestone: --- In PR 99716 I noted we don't complain about the fprintf in: FILE *fp = fopen ("/tmp/test", "w"); fprintf (fp, "hello"); fclose (fp); This becomes the following at the gimple ssa level: fp_7 = fopen ("/tmp/test", "w"); __builtin_fwrite ("hello", 1, 5, fp_7); fclose (fp_7); and we have: DEF_LIB_BUILTIN (BUILT_IN_FWRITE, "fwrite", BT_FN_SIZE_CONST_PTR_SIZE_SIZE_FILEPTR, ATTR_NONNULL_LIST) so we should have complained due to the ATTR_NONNULL_LIST due to fp_7 being in the "unchecked" state in the "file" state machine. Turns out that sm-file.cc doesn't yet implement checks for the "unchecked" state, and probably should (or somehow be merged with sm-malloc.cc). Filing this here as it's probably a bit late to be adding this for GCC 11.