BUG in type pattern implementation
if a function does not have any post conditions but pre-conditions, these require a post guard still!
Example:
noinline
int foo( int[m] a, int[m] b)
{ return 42;}
int main()
{
return foo( [1], [1,2]);
}
This mismatch goes completely unnoticed!!!!
After type checking, we have:
inline
int{42} _MAIN::foo( int[.] a { ,NN } , int[.] b { ,NN } )
/*
* foo :: ---
*/
{
int{42} _rtpf_4_res__SSA0_1 { , NN } ;
int[.] b__SSA0_2 { , NN } ; /* declared: int[.] */
int[.] a__SSA0_2 { , NN } ; /* declared: int[.] */
int[.] b__SSA0_1 { , NN } ; /* declared: int[.] */
int[.] a__SSA0_1 { , NN } ; /* declared: int[.] */
int{42} _rtpf_4_res { , NN } ;
bool[*] _rtpf_0_pred { , NN } ;
_rtpf_0_pred = _MAIN::_rtpf_2_pre_foo( a, b) ;
a__SSA0_1, b__SSA0_1 = _guard_( a, b, _rtpf_0_pred);
a__SSA0_2 = _type_conv_( int[.], a__SSA0_1);
b__SSA0_2 = _type_conv_( int[.], b__SSA0_1);
_rtpf_4_res = _MAIN::_rtpf_3_impl_foo( a__SSA0_2, b__SSA0_2) ;
_rtpf_4_res__SSA0_1 = _type_conv_( int, _rtpf_4_res);
return( _rtpf_4_res__SSA0_1);
}
The problem is that _rtpf_4_res
correctly has type int{42}
but in case _rtpf_0_pred
turns out false, someone needs to stop the 42
from leaking out of the function!
so we need a guard there which "forces" the type back to int
as return type of the function.
Currently, the 42 is propagated and the optimiser happily throws away the entire function call....