Skip to content

Rust puts garbage in data structures containing static lists #5917

Closed

Description

@mstewartgallus

The following gist compiles incorrectly, and prints garbage instead of the correct value.

https://gist.github.com/sstewartgallus/5406626

Activity

  1. jdm commented on Apr 17, 2013

    @jdm
    Contributor

    I think I came across this when doing my work with consts; iirc, looking at the LLVM IR that this produces shows various weird pointer casts that end up passing the complete wrong value when printing the list.

  2. catamorphism commented on Jul 18, 2013

    @catamorphism
    Contributor

    Slightly better test case:

    use std::io;
    
    struct T (&'static [int]);
    static t : T = T (&'static [5, 4, 3]);
    fn main () {
        assert_eq!(t[0], 5);
    }
    

    Reproduced with 93c270c. Nominating for milestone 5, production-ready

  3. alexcrichton commented on Jul 18, 2013

    @alexcrichton
    Member

    I believe that this may be the cause of #7617

  4. added a commit that references this issue on Jul 27, 2013
  5. added a commit that references this issue on Jul 27, 2013
    32622ce
  6. added 2 commits that reference this issue on Aug 28, 2020
    5b07b9e
    f21d10b
  7. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions