Skip to content
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

Declaring nt_checked array of size 0 should be illegal #1137

Open
secure-sw-dev-bot opened this issue Jan 17, 2022 · 1 comment
Open

Declaring nt_checked array of size 0 should be illegal #1137

secure-sw-dev-bot opened this issue Jan 17, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@secure-sw-dev-bot
Copy link

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


We have the following code in test/CheckedC/inferred-bounds/bounds-context.c:

void f(char p nt_checked[0] : count(len), unsigned len) {}

The compiler currently allows this because p has a declared bounds of count(len). But this declaration conflicts with the empty size declaration which is illegal.

Also if we remove the declared bounds then the compiler asserts.

void f(char p nt_checked[0]) {}

clang: /usr/magrang/master/src/clang/lib/Sema/BoundsUtils.cpp:57: 
static clang::BoundsExpr* clang::BoundsUtil::CreateBoundsForArrayType(clang::Sema&, clang::QualType, bool):
Assertion `size.uge(1) && "must have at least one element"' failed.
@secure-sw-dev-bot secure-sw-dev-bot added the bug Something isn't working label Jan 17, 2022
@secure-sw-dev-bot
Copy link
Author

Comment from @mattmccutchen-cci:

We have the following code in test/CheckedC/inferred-bounds/bounds-context.c:

void f(char p nt_checked[0] : count(len), unsigned len) {}

The compiler currently allows this because p has a declared bounds of count(len). But this declaration conflicts with the empty size declaration which is illegal.

Duplicate of #1071?

Also if we remove the declared bounds then the compiler asserts.

void f(char p nt_checked[0]) {}

clang: /usr/magrang/master/src/clang/lib/Sema/BoundsUtils.cpp:57: 
static clang::BoundsExpr* clang::BoundsUtil::CreateBoundsForArrayType(clang::Sema&, clang::QualType, bool):
Assertion `size.uge(1) && "must have at least one element"' failed.

Duplicate of #1130?

If indeed both parts of this issue are duplicates, maybe it can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant