Skip to content

zero-sized slices are sometimes placed at 0x1 (1.79+) #128257

Closed
@flaub

Description

@flaub

I tried this code:

fn main() {
    println!("{:?}", b"".as_ptr());
    println!("{:?}", b"1".as_ptr());
}

In 1.78, this is the output:

0x104cd9440
0x104cd9442

However on 1.79+, this is the output:

0x1
0x100356da1

How can this not be a major breaking change? It doesn't seem sensible that as_ptr() can return a value like 0x01.

Meta

rustc --version --verbose:

rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: aarch64-apple-darwin
release: 1.79.0
LLVM version: 18.1.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions