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

Static expression fails constraint check on generated code #726

Closed
jklmnn opened this issue Aug 10, 2021 · 0 comments · Fixed by #734
Closed

Static expression fails constraint check on generated code #726

jklmnn opened this issue Aug 10, 2021 · 0 comments · Fixed by #734
Assignees

Comments

@jklmnn
Copy link
Member

jklmnn commented Aug 10, 2021

When a field value is used in calculations and the result is larger than the field the generated code will not compile but fail with a static constraint check.

package Test is

   type Length_Type is mod 2 ** 8;

   type Packet is
      message
         Length_1 : Length_Type;
         Length_2 : Length_Type
            then Payload
               with Size => Length_2 * 256 + Length_1
               if (Length_2 * 256 + Length_1) mod 8 = 0;
         Payload : Opaque;
      end message;

end Test;

This will lead to the following error on the generated code:

rflx-test-packet.adb:444:100: error: value not in range of type "Length_Type" defined at rflx-test.ads:16
rflx-test-packet.adb:444:100: error: static expression fails Constraint_Check
@jklmnn jklmnn created this issue from a note in RecordFlux 0.6 (To do) Aug 10, 2021
@treiher treiher self-assigned this Aug 10, 2021
@treiher treiher moved this from To do to In progress in RecordFlux 0.6 Aug 10, 2021
@treiher treiher moved this from In progress to Under review in RecordFlux 0.6 Aug 10, 2021
RecordFlux 0.6 automation moved this from Under review to Merged Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants