Skip to content

Declaring nt_checked array of size 0 should be illegal #1137

Open
@secure-sw-dev-bot

Description

@secure-sw-dev-bot

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions