Skip to content

const fn can cause infinite recursion in rustc #31364

Closed
@oli-obk

Description

@oli-obk
#![feature(const_fn)]
const fn a() -> usize { b() }
const fn b() -> usize { a() }
const ARR: [i32; a()] = [5; 6];

fn main(){}

thread 'rustc' has overflowed its stack

The same problem happens in trans when using static A: usize = a(); instead.

Since we do not have constant conditionals, there's currently no way recursion ever makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions