Skip to content

Commit 7e97089

Browse files
committed
Adapt to effective types checks for pointer vars
Fixes two cases where the tutorial was not compliant with VeriFast's new checks for compliance with C's effective types rules when accessing variables of pointer type (see verifast/verifast#542).
1 parent 8acf339 commit 7e97089

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tutorial.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ \section{By-Reference Parameters}\label{section:byref-params}
17561756
second argument is the current value of the variable.
17571757

17581758
It follows that the following is a valid contract for function
1759-
\lstinline!nodes_filter!:
1759+
\lstinline!nodes_filter!:\footnote{This sentence is \emph{almost} true. This is a valid contract for function \lstinline!nodes_filter! only if C's \emph{effective types} rules are disabled, by specifying \lstinline|-fno-strict-aliasing| on the C compiler's and VeriFast's command line, or by checking \emph{Assume untyped memory} in the VeriFast IDE's Verify menu. To verify compliance with C's effective types rules when accessing the variable pointed to by \lstinline|n| as a variable of type \lstinline|struct node *|, VeriFast checks that that is that variable's \emph{effective type}, expressed in VeriFast syntax as \lstinline|has_type(node, &typeid(struct node *)) == true|. You can ignore this complexity by using the points-to syntax \lstinline!*n |-> ?node!, which implies both the \lstinline|pointer| chunk and the \lstinline|has_type| fact.}
17601760
\begin{lstlisting}
17611761
void nodes_filter(struct node **n, int_predicate *p)
17621762
//@ requires pointer(n, ?node) &*& nodes(node, _) &*& is_int_predicate(p) == true;
@@ -4254,7 +4254,7 @@ \section{Arrays of Pointers}\label{section:arrays-of-pointers}
42544254
printf("How many students do you have? ");
42554255
int n = read_int();
42564256
if (n < 0 || 0x20000000 <= n) abort();
4257-
char **names = malloc(n * sizeof(char **));
4257+
char **names = malloc(n * sizeof(char *));
42584258
if (names == 0) abort();
42594259
for (int i = 0; i != n; i++) {
42604260
printf("Please enter the name of student number %d: ", i + 1);

0 commit comments

Comments
 (0)