Skip to content

Type-checking error leads to compiler crash. #291

Closed
@dtarditi

Description

@dtarditi

The following snippet of incorrect code causes the debug build of the compiler to assert:

struct S {
  int arr _Checked[10];
  int data;
};

void passing_test_2(int i) {
  struct S s = { { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, 10 };
  s->arr[i] = 1;
}

Here is the output and the line of the assert. The compiler is crashing during the checking of bounds declarations.

D:\test>%clang% -fcheckedc-extension tmp.c
tmp.c:8:4: error: member reference type 'struct S' is not a pointer; did you mean to use '.'?
  s->arr[i] = 1;
  ~^~
   .
Assertion failed: E->isLValue(), file D:\llvm\tools\clang\lib\Sema\SemaBounds.cpp, line 402

The assert is double-checking that an expression is an lvalue as expected.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions