-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Writing to a static is somehow allowed while initializing that same static #142404
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
I tried this code:
I expected to see this happen: An error of some sort, or Miri reports UB.
Instead, this happened: The program compiles and outputs
0. Miri does not detect UB.Note that writing to a static while initializing a different static is not allowed. For example,
this produces the following error
Meta
Reproducible on the playground with
1.89.0-nightly (2025-06-11 e703dff8fe220b78195c)@rustbot labels +A-const-eval