Skip to content

Commit 67506ee

Browse files
authored
Merge pull request diffblue#4283 from tautschnig/fprintf
C library: Do not require stdin, stdout, stderr to be initialised
2 parents a622d44 + 92a3802 commit 67506ee

File tree

5 files changed

+199
-144
lines changed

5 files changed

+199
-144
lines changed

regression/cbmc-library/fileno-01/main.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33

44
int main()
55
{
6-
fileno();
7-
assert(0);
6+
// requires initialization of stdin/stdout/stderr
7+
// assert(fileno(stdin) == 0);
8+
// assert(fileno(stdout) == 1);
9+
// assert(fileno(stderr) == 2);
10+
11+
int fd;
12+
FILE *some_file = fdopen(fd, "");
13+
assert(fileno(some_file) >= -1);
14+
815
return 0;
916
}

regression/cbmc-library/fileno-01/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33
--pointer-check --bounds-check
44
^EXIT=0$
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include <assert.h>
22
#include <stdio.h>
33

4-
int main()
4+
int main(int argc, char *argv[])
55
{
6-
fprintf();
7-
assert(0);
6+
fprintf(stdout, "some string %s: %d\n", argv[0], 42);
7+
fprintf(stderr, "some other string\n");
88
return 0;
99
}

regression/cbmc-library/fprintf-01/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33
--pointer-check --bounds-check
44
^EXIT=0$

0 commit comments

Comments
 (0)