-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-codegenArea: Code generationArea: Code generationA-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.
Description
According to analysis performed by @bjorn3, this code actually leads to two allocations containing 42
, i.e., FOO
and BAR
point to different things. The linker later merges the two, so the issue is currently not directly observable. However, it becomes observable when things are mutable.
I think this is a bug. When a static is defined as pub static BAR: &i32 = crate::a::FOO;
, IMO we should guarantee that BAR
and FOO
have the same value. I see no lee-way here for duplicating the memory they both point to.
Cc @oli-obk
EkremDincel, jtmoon79, khoover, tylerarnold, tarcieri and 1 moretarcieri
Metadata
Metadata
Assignees
Labels
A-codegenArea: Code generationArea: Code generationA-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.