Skip to content

Compiler generates incorrect use of localloc instruction for stackalloc feature in C# 7.2 #21918

@gafter

Description

@gafter

Before C# 7.2, the stackalloc feature could only be used in unsafe code, so it was the programmer's responsibility to ensure it is used safely. In 7.2, we are permitting it to be used in safe code (as part of the Span feature). So the compiler/language must ensure it is used in such a way that the compiler can generate correct code.

The following constraints regarding the CLI localloc instruction are not currently obeyed by the implementation in the features/readonly-ref branch:

The localloc instruction cannot occur within an exception block: filter, catch, finally, or fault.

Correct CIL required that the evaluation stack be empty, apart from the size item.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions