-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement restrictions on variables at external scope #40
Comments
Comment from @mattmccutchen-cci: Note: What was section 3.2 at the time this issue was filed (in this revision) is now section 3.6.4 (in this revision). Section 3.6.4 says: "All places in a program that may write to a variable with external scope also must have the same view of the bounds declarations involving that variable. This allows static checking to ensure that bounds declarations remain valid." However, the rule proposed later in the section is not sufficient to guarantee that property across translation units. Here's an example based on the one in section 3.6.4:
extern int size;
extern void update_size(int i);
#pragma CHECKED_SCOPE on
#include "shared.h"
void update_size(int i) {
size = i;
}
#pragma CHECKED_SCOPE on
#include "shared.h"
int size;
_Array_ptr<int> ap : count(size);
int arr _Checked[10];
int main(void) {
size = 10;
ap = arr;
update_size(100000000);
ap[99999999] = 0xbad; // SIGSEGV
return 0;
} Is this yet another problem the programmer is obliged to check for manually if they want a guarantee of spatial memory safety, or do we want to try to address it in the language? If the latter, we'd somehow need to know when compiling extern int size _Used_by_bounds(ap);
extern void update_size(int i); Then the compiler would reject the assignment in As this proposal stands, an attempt to take a |
This issue was copied from checkedc/checkedc-clang#40
Section 3.2 describes restrictions on variables at external scope that have bounds declarations. These restrictions need to be implemented.
The text was updated successfully, but these errors were encountered: