This patch adds a testcase for passing a closed fd to a function
that does not emit any warning.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/fd-4.c: Add a new testcase to demonstrate
passsing of a closed file descriptor to a function that does
not emit any warning.
Signed-off-by: Immad Mir <mirimmad@outlook.com>
+#include <stdio.h>\r
+\r
int open(const char *, int mode);\r
void close(int fd);\r
int write (int fd, void *buf, int nbytes);\r
/* {dg-message "\\(3\\) 'write' on closed file descriptor 'fd'; 'close' was at \\(2\\)" "" {target *-*-*} .-1 } */\r
}\r
}\r
+\r
+void\r
+test_5 (const char *path)\r
+{\r
+ int fd = open (path, O_RDWR);\r
+ close(fd);\r
+ printf("%d", fd); /* { dg-bogus "'printf' on a closed file descriptor 'fd'" } */\r
+}
\ No newline at end of file