Skip to content

const-eval: support (symbolic) distance between two pointers #160083

Description

@RalfJung

LLVM and linkers apparently can represents the distance between two symbols symbolically, but currently there is no way to get rustc to emit those instructions. The proper way to implement this would be for const-eval to have symbolic values that represent the distance between two pointers. That's possible but it's a non-trivial extension of the core const-eval machinery.

This comes up in our Windows SEH code that really would like compile-time pointer distance, and works around it with lazy initialization at runtime that is technically UB.

I don't know if that is a strong enough usecase to warrant supporting this, but it is at least worth tracking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-linkageArea: linking into static, shared libraries and binariesC-feature-requestCategory: A feature request, i.e: not implemented / a PR.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions