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

Compilation fails due to suspicious modulus value #316

Closed
treiher opened this issue Jul 1, 2020 · 3 comments · Fixed by #318
Closed

Compilation fails due to suspicious modulus value #316

treiher opened this issue Jul 1, 2020 · 3 comments · Fixed by #318
Assignees
Labels
bug generator Related to generator package (SPARK code generation)

Comments

@treiher
Copy link
Collaborator

treiher commented Jul 1, 2020

package Test is

     type A is mod 32;

end Test;
rflx-test.ads:7:18: warning: 2 ** 32 may have been intended here [-gnatw.m]

   compilation of rflx-test.ads failed
  7    type A is mod 32;

-gnatw.m
Activate warnings on suspicious modulus values.

This switch activates warnings for modulus values that seem suspicious. The cases caught are where the size is the same as the modulus (e.g. a modulus of 7 with a size of 7 bits), and modulus values of 32 or 64 with no size clause. The guess in both cases is that 2**x was intended rather than x. In addition expressions of the form 2*x for small x generate a warning (the almost certainly accurate guess being that 2**x was intended). The default is that these warnings are given.

I would suggest to disable that switch. @senier @jklmnn What is your opinion?

@treiher treiher added bug generator Related to generator package (SPARK code generation) labels Jul 1, 2020
@treiher treiher self-assigned this Jul 1, 2020
@treiher treiher added this to To do in RecordFlux 0.4.1 via automation Jul 1, 2020
@treiher treiher mentioned this issue Jul 1, 2020
26 tasks
@senier
Copy link
Member

senier commented Jul 1, 2020

I would suggest to disable that switch. @senier @jklmnn What is your opinion?

If I interpret the help message correctly, we could also consider to always add a size clause to modular types. OTOH, this heuristics does not seem to be too helpful. I have no strong opinion.

@jklmnn
Copy link
Member

jklmnn commented Jul 1, 2020

We already had this case once in regular code where we decided to use 2 ** 5 instead.

@treiher
Copy link
Collaborator Author

treiher commented Jul 1, 2020

we could also consider to always add a size clause to modular types

Let's try that. This has the advantage that the user does not get this warning for generated code (-gnatw.m is activated by default).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug generator Related to generator package (SPARK code generation)
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants