Skip to content

An nt_checked array with an empty initializer list should be an error#1121

Merged
mgrang merged 1 commit into
masterfrom
fix_1120
Jul 7, 2021
Merged

An nt_checked array with an empty initializer list should be an error#1121
mgrang merged 1 commit into
masterfrom
fix_1120

Conversation

@mgrang

@mgrang mgrang commented Jul 7, 2021

Copy link
Copy Markdown

Consider the following declaration of an nt_checked array:
char p nt_checked[] = {}

According to the Checked C spec section 2.4:

  1. nt_checked declares an array whose last element is a null terminator. The size
    of the array includes the null terminator element.

  2. An nt_checked array with size d converts to an nt_array_ptr with a count of d -
    1 elements.

So it should be illegal to declare an nt_checked array with an empty initializer list.

This fixes issue #1120.

Consider the following declaration of an nt_checked array:
char p nt_checked[] = {}

According to the Checked C spec section 2.4:

1. nt_checked declares an array whose last element is a null terminator. The size
   of the array includes the null terminator element.

2. An nt_checked array with size d converts to an nt_array_ptr with a count of d -
   1 elements.

So it should be illegal to declare an nt_checked array with an empty initializer list.

This fixes issue #1120.

@sulekhark sulekhark left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

@kkjeer kkjeer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants