Skip to content

Calling tuple struct constructor as a function causes segfault #5315

Description

@lifthrasiir

This code segfaults (as of a5fae1d 2013-03-08 18:15:40 -0800).

struct A(int);
fn main() {
    let f: extern pure fn(int) -> A = A; f(4);
}

Note that extern pure fn(int) -> A is an exact type reported by the compiler for A. This occurs for arbitrary number of fields. Replacing the body of main to A(4); fixes the segfault.

Activity

  1. catamorphism commented on May 9, 2013

    @catamorphism
    Contributor

    Reproduced with 517bfc9 .

    The bug also comes up if you omit the type signature on f. I poked at this a little bit -- it looks like trans stores a **fn(int) into f, but the code generated for the call f(4) treats `fas if it's a*f``. Then I got confused as to which part of the code was correct. I think this isn't critical for 0.7.

  2. catamorphism commented on May 9, 2013

    @catamorphism
    Contributor

    Nominating for milestone 5 (production-ready).

  3. graydon commented on May 16, 2013

    @graydon
    Contributor

    accepted for production-ready milestone

  4. emberian commented on Jun 22, 2013

    @emberian
    Contributor

    tuple struct constructor as function is going away with a patch I'm working on.

  5. emberian commented on Aug 5, 2013

    @emberian
    Contributor

    So that patch never really worked out. But, this is still relevant, and reproduces.

  6. added a commit that references this issue on Aug 21, 2013
    48dded9
  7. added a commit that references this issue on Aug 21, 2026
  8. added a commit that references this issue on Sep 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

    A-codegenArea: Code generationI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions