File tree Expand file tree Collapse file tree 5 files changed +62
-0
lines changed
Expand file tree Collapse file tree 5 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ #include <assert.h>
2+ #include <stdlib.h>
3+
4+ int main ()
5+ {
6+ int r = rand ();
7+ assert (r >= 0 );
8+ return 0 ;
9+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+ --pointer-check --bounds-check
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ ^VERIFICATION SUCCESSFUL$
7+ --
8+ ^warning: ignoring
Original file line number Diff line number Diff line change 1+ #include <assert.h>
2+ #include <stdlib.h>
3+
4+ int main ()
5+ {
6+ unsigned int seed ;
7+ int r = rand_r (& seed );
8+ assert (r >= 0 );
9+ return 0 ;
10+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+ --pointer-check --bounds-check
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ ^VERIFICATION SUCCESSFUL$
7+ --
8+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -564,3 +564,30 @@ long random(void)
564564 __CPROVER_assume (result >=0 && result <=2147483647 );
565565 return result ;
566566}
567+
568+ /* FUNCTION: rand */
569+
570+ int __VERIFIER_nondet_int ();
571+
572+ int rand (void )
573+ {
574+ __CPROVER_HIDE :;
575+ // We return a non-deterministic value instead of a random one.
576+ int result = __VERIFIER_nondet_int ();
577+ __CPROVER_assume (result >= 0 );
578+ return result ;
579+ }
580+
581+ /* FUNCTION: rand_r */
582+
583+ int __VERIFIER_nondet_int ();
584+
585+ int rand_r (unsigned int * seed )
586+ {
587+ __CPROVER_HIDE :;
588+ // We return a non-deterministic value instead of a random one.
589+ (void )* seed ;
590+ int result = __VERIFIER_nondet_int ();
591+ __CPROVER_assume (result >= 0 );
592+ return result ;
593+ }
You can’t perform that action at this time.
0 commit comments