You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we have a function whose return bounds are specified via a bounds-safe interface, e.g.
int *f(int *p, int *q : count(3), int test) : count(4) {
...
}
If a return statement within the body of f occurs within an unchecked scope and:
The return value has unchecked pointer type, or:
The return value has a bounds-safe interface, then:
The compiler should not emit any errors or warnings that would otherwise result from checking that the bounds of the return value imply the declared bounds of f.
For example, in the function below, return p should not result in any errors even though the bounds of p are bounds(unknown). return q should not result in any errors even though the bounds of q (bounds(q, q + 3)) are too narrow for the declared bounds of f (bounds(_Return_value, _Return_value + 4)).
int *f(int *p, int *q : count(3), int test) : count(4) _Unchecked {
if (test > 0)
return p;
else
return q;
}
However, if a return statement within the body of f occurs within an unchecked scope and the return value has checked pointer type, the compiler should emit any errors or warnings that result from checking that the bounds of the return value imply the declared bounds of f.
For example, in the function below, return r should result in an error since the bounds of r are unknown. return s should result in an error since the bounds of s (bounds(s, s + 3)) are too narrow for the declared bounds of f (bounds(_Return_value, _Return_value + 4)).
int *f(_Array_ptr<int> r : bounds(unknown), _Array_ptr<int> s : count(3), int test) : count(4) _Unchecked {
if (test > 0)
return r;
else
return s;
}
The text was updated successfully, but these errors were encountered:
This issue was copied from checkedc/checkedc-clang#1157
If we have a function whose return bounds are specified via a bounds-safe interface, e.g.
If a return statement within the body of
f
occurs within an unchecked scope and:The compiler should not emit any errors or warnings that would otherwise result from checking that the bounds of the return value imply the declared bounds of
f
.For example, in the function below,
return p
should not result in any errors even though the bounds ofp
arebounds(unknown)
.return q
should not result in any errors even though the bounds ofq
(bounds(q, q + 3)
) are too narrow for the declared bounds off
(bounds(_Return_value, _Return_value + 4)
).However, if a return statement within the body of
f
occurs within an unchecked scope and the return value has checked pointer type, the compiler should emit any errors or warnings that result from checking that the bounds of the return value imply the declared bounds off
.For example, in the function below,
return r
should result in an error since the bounds ofr
are unknown.return s
should result in an error since the bounds ofs
(bounds(s, s + 3)
) are too narrow for the declared bounds off
(bounds(_Return_value, _Return_value + 4)
).The text was updated successfully, but these errors were encountered: