﻿id	summary	reporter	owner	description	type	status	priority	component	version	resolution	keywords	cc
259	Compiler crash on large recursive assertion requests	mlbrooks		"This bug report is the closest we have to a reproduction of intermittent failures seen in the array-md-sbscr-cases test.

That test, as written 2022-April-09, fails intermittently on 32-bit overnight builds, cannot be made to fail manually (even on 32-bit), and succeeds on 64-bit.

The case in here fails deterministically when run manually on 32-bit and succeeds on 64-bit.  It fails with the same symptom as in the failed overnight build logs.

The case in here is edited substantially, to remove unnecessary features of array.hfa and all but a minimal repro based on the array-md-sbscr-cases test.

{{{
forall( __CFA_tysys_id_only_X & ) struct tag {};


forall( [N], S &, Timmed &, Tbase & ) {
    struct thing {};

    // get1, first alternative (int overload)
    Timmed & get1( thing(N, S, Timmed, Tbase) & a, int i );
}


forall( TA &, TB &, TC &, IxAB_0, IxBC | { TB & get1( TA &, IxAB_0 ); TC & get1( TB &, IxBC ); } )
TC & get2( TA & this, IxAB_0 ab, IxBC bc );

forall( TA &, TB &, TC &, IxAB_0, IxAB_1, IxBC | { TB & get2( TA &, IxAB_0, IxAB_1 ); TC & get1( TB &, IxBC ); } )
TC & get3( TA & this, IxAB_0 ab0, IxAB_1 ab1, IxBC bc );

forall( TA &, TB &, TC &, IxAB_0, IxAB_1, IxAB_2, IxBC | { TB & get3( TA &, IxAB_0, IxAB_1, IxAB_2 ); TC & get1( TB &, IxBC ); } )
TC & get4( TA & this, IxAB_0 ab0, IxAB_1 ab1, IxAB_2 ab2, IxBC bc );


// Base
forall( [Nq], Sq &, Tbase & )
tag(thing(Nq, Sq, Tbase, Tbase)) enq_( tag(Tbase), tag(Nq), tag(Sq), tag(Tbase) );

// Rec
forall( [Nq], Sq &, [N], S &, recq &, recr &, Tbase & | { tag(recr) enq_( tag(Tbase), tag(Nq), tag(Sq), tag(recq) ); } )
tag(thing(N, S, recr, Tbase)) enq_( tag(Tbase), tag(Nq), tag(Sq), tag(thing(N, S, recq, Tbase)) );

struct all_t {} all;

// get1, second alternative (""all"" overload)
forall( [N], S &, Te &, result &, Tbase & | { tag(result) enq_( tag(Tbase), tag(N), tag(S), tag(Te) ); } )
result & get1( thing(N, S, Te, Tbase) & this, all_t );


void test() {

    thing(5, char, thing(6, char, thing(7, char, thing(8, char, float, float), float), float), float) wxyz;

    float ans1 = get1( get4( wxyz, all, 3, 4,   5 ), 2 );  // works everywhere
    float ans2 = get1( get4( wxyz, 2,   3, all, 5 ), 4 );  // crashes on 32bit, works on 64bit

    float ans3 = get1( get1( get1( get1( get1( wxyz, 2 ), 3), all), 5 ), 4 );  // works everywhere (is the intended expansion of get4 from ans2)
}
}}}

cfa -c thistest.cfa

32-bit, as-is, actual: compiler error, with message beginning
{{{
CFA Version 1.0.0 (debug)
*CFA assertion error* ""inferParam != appExpr->inferParams.end()"" from program ""cfa-cpp"" in ""void GenPoly::{anonymous}::Pass1::addInferredParams(ApplicationExpr*, FunctionType*, std::__cxx11::list<Expression*>::iterator&, const TyVarMap&)"" at line 801 in file ""../../cfa-cc/src/GenPoly/Box.cc"": addInferredParams missing inferred parameter: enq_: extern pointer to function
}}}

32-bit, as-is, expected;
32-bit, edited to remove the ""crashes"" line, actual and expected;
64-bit, as-is, actual and expected:
compilation finishes and produces a *.o file
"	defect	new	major	cfa-cc	1.0			
