Skip to content

make static empty_array to be constexpr - #1682

Open
Shamzik wants to merge 1 commit into
masterfrom
kshamazov/costexpr_empy_array
Open

make static empty_array to be constexpr#1682
Shamzik wants to merge 1 commit into
masterfrom
kshamazov/costexpr_empy_array

Conversation

@Shamzik

@Shamzik Shamzik commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Protects the empty array instance from accidental modifications.

Problem

The global empty array instance lacked strict compile-time protection against mutability.

Solution

Enforced Const Correctness: Marked the internal static empty_array representation as constexpr to ensure it is evaluated at compile time and placed in read-only memory.

Impact

Enhances memory safety by guaranteeing that the empty array state cannot be accidentally altered at runtime.

@Shamzik Shamzik added runtime Feature related to runtime k2 Affects compiler or runtime in K2 mode kphp Affects compiler or runtime in default mode (not K2) labels Aug 26, 2026
@Shamzik Shamzik added this to the next milestone Aug 26, 2026
@Shamzik Shamzik self-assigned this Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

k2 Affects compiler or runtime in K2 mode kphp Affects compiler or runtime in default mode (not K2) runtime Feature related to runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant