2 ms·
I want to like the idea, but to me the examples looks like the abomination that was (is?) managed C++. As per wiki, they state that they have automatic convers
by galkk 6y ago
I want to like the idea, but to me the examples looks like the abomination that was (is?) managed C++.
As per wiki, they state that they have automatic conversion tools, but I highly doubt that this will be used in production, even in Microsoft.
Example from their wiki (https://github.com/microsoft/checkedc/blob/master/samples/string-helpers.c#L140 https://github.com/microsoft/checkedc/blob/master/samples/st...):
// Delete all c from p (adapted from p. 47, K&R 2nd Edition)
// p implicitly has count(0).
checked void squeeze(nt_array_ptr<char> p, char c) {
int i = 0, j = 0;
// Create a temporary whose count of elements can
// change.
nt_array_ptr<char> s : count(i) = p;
for ( ; s[i] != '\0'; i++) {
// We need to widen the bounds of s so that we
// can assign to s[j] when j == i.
// (In the long run, this will be taken care of by the
// flow-sensitive bounds widening).
nt_array_ptr<char> tmp : count(i + 1) = s;
if (tmp[i] != c)
tmp[j++] = tmp[i];
}
// if i==j, this writes a 0 at the upper bound. Writing a 0 at the upper bound
// is allowed for pointers to null-terminated arrays. It is not allowed for
// regular arrays.
s[j] = 0;
}