Skip to content

Regression in goto-cc since PR #2490 switch-range was merged #2583

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

Closed
chrisr-diffblue opened this issue Jul 17, 2018 · 5 comments
Closed

Regression in goto-cc since PR #2490 switch-range was merged #2583

chrisr-diffblue opened this issue Jul 17, 2018 · 5 comments

Comments

@chrisr-diffblue
Copy link
Contributor

The following example:

#define C1 (int) ( 0. / 1. + 0.5)
#define C2 (int) ( 1. / 1. + 0.5)

extern int g_c;
int g_out;

void main(void)
{
  switch (g_c)
  {
  case C1:
      g_out = 1;
      break;
  case C2:
      g_out = 2;
      break;
  default:
       break;
  }
}

Used to be able to be compiled by goto-cc, but since #2490 was merged this example now fails to compile due to a type check failure:

goto-cc test.c
test.c: In function 'main':
test.c:11:1: error: expected constant expression, but got `(signed int)(0.0 / 1.0 + 0.5)'
CONVERSION ERROR
@chrisr-diffblue
Copy link
Contributor Author

The closed/abandoned PR #2076 and/or the merged PR #2081 may have some hints as to how to solve this.

@tautschnig
Copy link
Collaborator

Maybe we shouldn't strictly require that the result is a single constant, and instead accept expressions that solely consist of constants (and type casts).

@chrisr-diffblue
Copy link
Contributor Author

That would be one option - though it seems theres a number of places that we've recently tripped over cases where this kind of constant FP operation isn't currently handled - so maybe we really should attempt a better fix to simplify() to handle this kind of expression?

@tautschnig
Copy link
Collaborator

Sure, if we can fix simplify() then that's even better!

@chrisr-diffblue
Copy link
Contributor Author

I won't get chance to look this week, but I'll see if I can make some time next week...

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

2 participants