Skip to content

Docs indicate that statics are never inlined, but this is not true as of rustc 1.25 #322

Closed
@ncoish

Description

@ncoish

The docs indicate that a static is never inlined:
https://doc.rust-lang.org/beta/reference/items/static-items.html#static-items

However, as of rust 1.25 stable, it seems that statics are actually occasionally inlined, even in debug mode. See the ASM generated here; main directly inlined a and b as $89858 and $89860: https://play.rust-lang.org/?gist=16ecb92477b3b447e3b4131d956ca5b6&version=stable&mode=debug

I discovered this because some of our test automation code was patching our binary to modify the executable to change a static, but those tests are now broken since we can no longer rely on the statics being a precise memory location. This is fine, but the docs should be updated to reflect this.

Metadata

Metadata

Assignees

Labels

C-bugIncorrect statements, terminology, or rendering issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions