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 #1138

Open
mgrang opened this issue Jul 27, 2021 · 1 comment
Open

Declaring nt_checked array of size 0 should be illegal #1138

mgrang opened this issue Jul 27, 2021 · 1 comment
Labels
bug This labels issues that are bugs.

Comments

@mgrang
Copy link

mgrang commented Jul 27, 2021

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.
@mattmccutchen-cci
Copy link
Member

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 This labels issues that are bugs.
Projects
None yet
Development

No branches or pull requests

2 participants