Skip to content

Commit 7f986ec

Browse files
authored
Disallow array_ptrs to function types. (checkedc#204)
Update the specification to disallow array_ptrs of function types. Bounds checking pointers to function types does not make sense because functions do not have sizes in C. This addiresses issue checkedc#34. Also correct the capitalization of the _Nt_array_ptr keyword in the specification.
1 parent e4690c6 commit 7f986ec

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

spec/bounds_safety/core-extensions.tex

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ \section{New keywords}
2222
begin with two underscores \cite[Section 7.1.3]{ISO2011}. The following
2323
new keywords are introduced:
2424
\begin{verbatim}
25-
_Array_ptr _Checked _Dynamic_check _Nt_Array_ptr _Nt_checked _Ptr
25+
_Array_ptr _Checked _Dynamic_check _Nt_array_ptr _Nt_checked _Ptr
2626
_Where _Unchecked
2727
\end{verbatim}
2828

@@ -140,6 +140,15 @@ \section{New kinds of pointer types}
140140
\keyword{const} value can be assigned a pointer to a non-const value.
141141
The reverse is not allowed.
142142

143+
Array pointers (\arrayptr) of function types are not allowed. Functions have
144+
no size associated with them, so bounds checking pointers to them does not
145+
make sense. Programmers should use \ptr\ instead:
146+
\begin{verbatim}
147+
typedef array_ptr<int (int x, int y)> callback_fn; // illegal
148+
typedef ptr<int (int x, int y)> callback_ptr; // legal
149+
typedef array_ptr<callback_ptr> callback_arr; // legal
150+
\end{verbatim}
151+
143152
\section{New kinds of array types}
144153

145154
A new checked array type is added to C. Just as there are checked pointer

0 commit comments

Comments
 (0)