Closed
Description
Rustc's constant expression evaluation overflows in stack while compiling this kind of code:
pub const CST_1: u32 = 0;
pub const CST_2: u32 = CST_1+1;
pub const CST_3: u32 = CST_2+1;
pub const CST_4: u32 = CST_3+1;
pub const CST_5: u32 = CST_4+1;
pub const CST_6: u32 = CST_5+1;
pub const CST_7: u32 = CST_6+1;
pub const CST_8: u32 = CST_7+1;
pub const CST_9: u32 = CST_8+1;
//...
pub const CST_350: u32 = CST_349+1;
On my machine (linux 64): ~350 constants on the chain is enough with rustc 1.10.0 (cfcb716 2016-10-03). What is quite troubling to me is that rustc seems to do the work for each constant and does not rely on previously computed results. One could think that Rust just always draws the short straw, but I tried random names and random order for my constants and got the same problem.
Also, on 1.12.0-nightly (936bfea 2016-07-20) and 1.11.0-beta.1 (8dc253b 2016-07-05), there is no stack overflow message just a painful silent abort (return code -1).