Skip to content

Jump on unitialized memory when returning from closure with --opt-level=2 #15932

Closed
@apoelstra

Description

@apoelstra

The following code has a valgrind error when compiled with --opt-level=2 or greater. I have a mystery crash in a program of mine whenever optimizations are enabled, and hitting this is the first sign of anything amiss.

use std::io::{IoError, standard_error, InvalidInput};

fn main() {
  (|err: IoError|
    match &match err.detail {
            Some(s) => "",
            _ => ""
          } {
      _ => box 0u
    }
  )(standard_error(InvalidInput));
}

The offending line is the box 0u. The weird match &match var { ... } { ... } expression comes from inside a format!

Edit: My crash had nothing to do with this. I don't think this is a serious bug.

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