================ @@ -339,3 +363,107 @@ void fflush_on_open_failed_stream(void) { } fclose(F); } + +void test_fscanf_eof() { + FILE *F1 = tmpfile(); + if (!F1) + return; + + int a; + unsigned b; + int ret = fscanf(F1, "%d %u", &a, &b); + char c = fgetc(F1); // expected-warning {{Read function called when stream is in EOF state. Function has no effect}} + // expected-warning@-1 {{File position of the stream might be 'indeterminate' after a failed operation. Can cause undefined behavior}} ---------------- NagyDonat wrote:
Do I understand it correctly that here the checker would print a note explaining that it assumes that `fscanf` reaches the end-of-file? Without that this checker behavior would be difficult to understand. https://github.com/llvm/llvm-project/pull/82476 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits