Skip to content

Add new kind of pointer type for null-terminated array_ptrs #215

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

Closed
secure-sw-dev-bot opened this issue Jan 16, 2022 · 1 comment
Closed
Labels

Comments

@secure-sw-dev-bot
Copy link

This issue was copied from checkedc/checkedc-clang#215


To handle null-terminated strings, we will need to have null-terminated array_ptrs. The current plan is to have a new kind of type, just as we have ptr and array_ptr. The new type might be called nullterm_ptr. We still need to write up the design of the type. It will likely be modelled on the support for null-terminated pointers described in the Deputy research project. Programmers will be able to optionally declare that a variable with null-terminated pointer type has a bounds expression.

This proposed work items are based on what we did to implement array_ptr:

  1. Extend the IR with a way to represent null-terminated array_ptr types. This includes extending AST dumping and pretty-printing.
  2. Add parsing of null-terminated array_ptr types.
  3. Restrict implicit conversions involving null-terminated array_ptr types:
  • An array_ptr type cannot be converted implicitly to a null-terminated array_ptr type. This is because there could be another copy of the pointer that allows the null value to be overwritten.
  • For similar reasons, unchecked pointer types cannot be converted implicitly to null-terminated array_ptr.
  • Null-terminated pointer types can be implicitly converted to array_ptr types.
  • Null terminated array_ptr pointers cannot be implicitly converted to an unchecked pointer type.
  1. Write tests of language constructs using null-terminated array_ptr
  • Expressions.
  • Function calls
  1. Extend existing interoperation support and write test of that.
  2. Add bounds checking for null-terminated array_ptr types. The bounds checks will be different than those allowed for array_ptr types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant