Checked C is an extension to C that lets programmers write C code that is guaranteed by the compiler to be type-safe. The goal is to let people easily make their existing C code type-safe and eliminate entire classes of errors. Checked C does not address use-after-free errors. This repo has a wiki for Checked C, sample code, the specification, and test code.
Перейти к файлу
David Tarditi 95aa444265
Test restrictions on taking addresses of members and variables. (#284)
Checked C restricts taking the addresses of:
1. Members with member bounds declarations.
2. Members used in member bounds declarations.
3. Variables with bounds declarations.
4. Variables/variable members used in bounds declarations.

This add tests of restrictions 1-3, as part of implementing https://github.com/Microsoft/checkedc-clang/issues/213 and https://github.com/Microsoft/checkedc-clang/issues/212:
- Taking the address of non-array members with or used in bounds declarations is now an error. 
- Taking the address of non-array members with or used in bounds-safe interfaces is allowed in unchecked scopes.  It is an error in checked scopes.
- Taking the address of non-array variables with bounds declaration is now an error.

It is OK to take the address of an array variable or member because you can't use the resulting pointer to modify the pointer that the array converts to.

The trickier cases to test involve nested members.  Given 
```
struct NestedLen {
   int len; 
};

struct S {
   struct NestedLen n;
   _Array_ptr<int> p : count(n.len);
}
```
we don't allow the addresses of `n` or `n.len` to be taken.  However, if `NestedLen` is not embedded in `S`, we allow the address of a struct of type NestedLen to be taken.
2018-05-21 15:19:06 -07:00
include Rename BOUNDS_CHECKED pragma to CHECKED_SCOPE. (#282) 2018-04-26 16:31:50 -07:00
papers/dynamic_checks Technical Report Number 2 (#248) 2018-01-22 13:22:39 -08:00
samples Rename BOUNDS_CHECKED pragma to CHECKED_SCOPE. (#282) 2018-04-26 16:31:50 -07:00
spec Update specification to match implementation. (#283) 2018-05-03 21:07:33 -07:00
tests Test restrictions on taking addresses of members and variables. (#284) 2018-05-21 15:19:06 -07:00
CONTRIBUTING.md Update CONTRIBUTING.md 2018-03-17 11:18:07 -07:00
LICENSE.TXT Update copyright notice. 2016-06-13 11:03:35 -07:00
MAILING-LISTS.md Update README.md and other md files. (#77) 2016-11-22 12:01:16 -08:00
README.md Update README.md 2018-05-09 12:58:47 -07:00
WishList.md Add a wish list of projects. (#27) 2016-06-15 09:44:04 -07:00

README.md

Checked C

Checked C adds static and dynamic checking to C to detect or prevent common programming errors such as buffer overruns and out-of-bounds memory accesses. The goal of the project is to improve systems programming by making fundamental improvements to C. This repo contains sample code, the extension specification, and test code.

  • For a quick overview of Checked C and more information, see our Wiki.
  • The PDF of the specifcation is available here.
  • Compilers are available here.

Build Status

Configuration Testing Status
Debug X86 Windows Checked C and clang regression tests Debug X86 Windows status
Debug X64 Windows Checked C and clang regression tests Debug X64 Windows status
Debug X64 Linux Checked C and clang regression tests Debug X64 Linux status
Release X64 Linux Checked C, clang, and LLVM nightly tests Release X64 Linux status

Participating

We're happy to have the help! You can contribute by trying out Checked C, reporting bugs, and giving us feedback. There are other ways to contribute too. You can join the mailing lists for announcements about the project.

Licensing

The software in this repository is covered by the MIT license. See the file LICENSE.TXT for the license. The Checked C specification is made available by Microsoft under the OpenWeb Foundation Final Specification Agreement, version 1.0. Contributions of code to the Checked LLVM/clang repos are subject to the CLANG/LLVM licensing terms.

Code of conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.