Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 394
    • Issues 394
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 17
    • Merge requests 17
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #2353
Closed
Open
Created Nov 16, 2023 by Sven-Bodo Scholz@sbsOwner

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....

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking