Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spurious Warning: Body of function ... falls-through and cannot find an appropriate return value #70

Open
michael-schwarz opened this issue Jan 27, 2022 · 0 comments

Comments

@michael-schwarz
Copy link
Member

Sometimes, particularly when dealing with code that CIL produced from code that contained a switch, we produce spurious warnings Warning: Body of function test falls-through and cannot find an appropriate return value.

E.g.

typedef struct s_0 {int a;} s;

s test(int param) {
    s one;
    switch(param) {
        case 3:
            one = (s){7};
            return one;
        default:
            one = (s){7};
            return one;
    }
}

int main() {
    test(7);
}

CIL transforms this into:

s test(int param ) 
{ 
  s one ;
  s __constr_expr_0 ;
  s __constr_expr_1 ;

  {
  {
  if (param == 3) {
    goto case_3;
  }
  goto switch_default;
  case_3: /* CIL Label */ 
  __constr_expr_0.a = 7;
  one = __constr_expr_0;
  return (one);
  switch_default: /* CIL Label */ 
  __constr_expr_1.a = 7;
  one = __constr_expr_1;
  return (one);
  switch_break: /* CIL Label */ ;
  }
}

When running CIL again on the CILed program we get the spurious warning.

This is a low priority issue discovered during goblint/bench#16 and I opened it mostly such that we can refer to it when we see this error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant