Skip to content

C library/time: fix wrong is-null test #5655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions regression/cbmc-library/time-01/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

int main()
{
time();
assert(0);
time_t t1 = time(0);

time_t t;
time_t t2 = time(&t);
assert(t2 == t);

return 0;
}
2 changes: 1 addition & 1 deletion regression/cbmc-library/time-01/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KNOWNBUG
CORE
main.c
--pointer-check --bounds-check
^EXIT=0$
Expand Down
3 changes: 2 additions & 1 deletion src/ansi-c/library/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ time_t __VERIFIER_nondet_time_t();
time_t time(time_t *tloc)
{
time_t res=__VERIFIER_nondet_time_t();
if(!tloc) *tloc=res;
if(tloc)
*tloc = res;
return res;
}

Expand Down