-
Notifications
You must be signed in to change notification settings - Fork 36
Add COMP-5 binary size test #197
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
base: gitside-gnucobol-3.x
Are you sure you want to change the base?
Conversation
|
That's good - let's expand this by adding the non P versions with expected same size and one run for each of the Thanks again! |
|
Updated. I'm a bit surprised by the results for |
|
yes, so the testcase uncovered a bug (that trunk may not have any more...) |
|
Also present in GC4. Apparently this is caused by this ( And this ( I'd say it suffices to not set But I'm also wondering, when |
Actually nope, I understand we must keep However removing the specific case for |
|
Rechecked (that complete check and specification below took more than two hours :-/ maybe I start to get old...): for Attention: Per GCOS docs the right binary-size option would be Also: acu-strict.conf currently has So I've gone through the annotate/blame to check where the changes come from. For field.c that's May 2007, history:r2575
That should obviously be the case and we should have a testcase for this... And this case was, back then, totally correct, which should answer your question. The real issue is the addition of the flag_real_binary to
This end result is correct (it is mostly about binary truncation instead of arithmetic one) but that actual change has an effect on the size generation as we found out - that it should not have for COMP-5! Even tree.h To fix it (you know, when you work on the test cases I can focus on the code...) case CB_USAGE_COMP_5:
- f->flag_real_binary = 1;and codegen.c: - if (f->flag_real_binary) {
+ if (f->flag_real_binary
+ || f->usage == CB_USAGE_COMP_5) {
flags |= COB_FLAG_REAL_BINARY;
}
if (f->flag_is_pointer) {
flags |= COB_FLAG_IS_POINTER;
}
- if (cb_binary_truncate &&
- f->usage == CB_USAGE_BINARY &&
- !f->flag_real_binary) {
+ if (cb_binary_truncate
+ && f->usage == CB_USAGE_BINARY
+ && !f->flag_real_binary) {
flags |= COB_FLAG_BINARY_TRUNC;
flags |= COB_FLAG_BINARY_TRUNC;
}
- if (type == COB_TYPE_NUMERIC_BINARY
- && f->usage == CB_USAGE_INDEX) {
- flags |= COB_FLAG_REAL_BINARY;
- type = COB_TYPE_NUMERIC_COMP5;
- } else
- if (type == COB_TYPE_NUMERIC_BINARY
- && (f->flag_binary_swap || f->flag_real_binary)
- && (f->flag_indexed_by || f->index_type || f->flag_internal_register)) {
- type = COB_TYPE_NUMERIC_COMP5;
+ if (type == COB_TYPE_NUMERIC_BINARY) {
+ if (f->usage == CB_USAGE_INDEX) {
+ flags |= COB_FLAG_REAL_BINARY;
+ type = COB_TYPE_NUMERIC_COMP5;
+ } else
+ if ((f->flag_binary_swap || f->flag_real_binary)
+ && (f->flag_indexed_by || f->index_type || f->flag_internal_register)) {
+ type = COB_TYPE_NUMERIC_COMP5;
+ }
}and of course Changelog: and NEWS +** #NNN: dialects without support of single byte binary data
+ will now generate at least 2 bytes of storage for COMP-5 elements; this
+ applies to all non-standard dialects but GnuCOBOL (default) and Micro Focus;
+ that changes the group length of records containing elements with less than
+ 3 digits and also passes different sizes via CALL, which may need program
+ adjustments.
+
+** -std=acu / -std=acu-strict now generate BINARY and COMP-5 with at least
+ 2 bytes of storage; the comment for #NNN above applies; if you want
+ to still use the sizes used since GnuCOBOL 2.2 with those dialects:
+ add -fbinary-size=1-2-4-8 to your compile options
+
* Important BugfixesWhich I think should both the existing testcases, the one you've added and the one new for If you prefer, I could also do this commit upstream. |
c99f785 to
63c7630
Compare
Yeah, that's definately something we should consider (back then, we just chosed what was the "closest").
Tests added ;)
Yup, reading the code a bit more, I get why this was made this way.
Yes, that seems to fix everything.
Well, I included your changes in this PR, so I can take care of that. |
GitMensch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please include the last change as well: config/acu-strict.conf (+Changelog)
-binary-size: 1-2-4-8 # not verified yet
+binary-size: 2-4-8 # TODO: add 2-4-8-12-16|
Done. Just realized I created the SVN ticket using a very old personal account of mine instead of my new "profesional" account - don't know if this can be changed... |
|
The creator change would need an export, adjustment and re-import, so there would have to be a very convincing reason to do so. But I've adjusted the text and assigned the ticket to your new account. BTW: congrats for this nice issue number :-) |
Alright.
Yeah, do I get a prize ? 😉 So, is this PR "ready for SVN" ? |
|
I've started doc + testsuite adjustments, with the later resulting in realizing about a missing feature...
If that's fine with you I'd do the upstream commit afterwards.
|
Alright, I leave it to you ;) |
|
Any news about this one ? |
Not sure if those adjustments have been made, but apparently the contents of this PR has not been integrated to 3.x yet. Shall I upstream it to SVN ? (@GitMensch ) |
|
Friendly ping, @GitMensch ;) |
|
Hi @GitMensch @ddeclerck any progress on this merge? The only conflicts are in cobc/ChangeLog and config/ChangeLog and these are easily resolved. It does fix the problem of PIC 9 COMP-5 being the wrong size (bug 1000), while still allowing BINARY-CHAR to be a 1-byte field, and it'd be nice if this bugfix could be merged before #248 |
|
Sorry, hold that last comment. I discovered a problem with this fix. When compiling with -fbinary-size=2-4-8 -ftrunc these statements all produce: warning: value size exceeds data size [-Wothers]: These should all be allowed because the idea of COMP-5 (on the mainframe at least, I don't know about MicroFocus) is that the values are limited by the size of the data item and not the number of 9's in the PIC, regardless of the TRUNC/NOTRUNC setting, unlike COMP which is affected by TRUNC/NOTRUNC. |
|
@ddeclerck @GitMensch This is the fix that I suggest:
This does pass the tests "Fixed BINARY size" and "COMP-5 binary size" added by this branch. It also compiles the above code snippet Attached patch file comp5-binary-size.patch |
|
I'll have a look but it likely takes a week until I find the opportunity to do so.
Roger Bowler ***@***.***> schrieb am Montag, 13. Oktober 2025 um 17:30:
… rbowler left a comment (OCamlPro/gnucobol#197)
@ddeclerck @GitMensch This is the fix that I suggest:
1. Revert the changes to field.c and codegen.c made by commit e766efe so that f->flag_real_binary will still be set for CB_USAGE_COMP_5
2. Add new bitflag flag_binary_char in the cb_field structure in tree.h
3. In field.c::validate_elementary_item() set f->flag_binary_char = 1 for cases CB_USAGE_SIGNED_CHAR and CB_USAGE_UNSIGNED_CHAR in addition to setting f->flag_real_binary
4. In field.c::compute_binary_size() replace
`if (f->flag_real_binary && size <= 2) {`
by
`if (f->flag_binary_char) {`
This does pass the tests "Fixed BINARY size" and "COMP-5 binary size" added by this branch. It also compiles the above code snippet `PIC 9(2) COMP-5 VALUE 234.` etc without warnings.
Attached patch file comp5-binary-size.patch
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
|
rbowler:comp5_test is a branch based upon ddeclerck:comp5_test. It contains the suggested fix above plus an additional test case (COMP-5 binary values) which tests COMP-5 values which exceed the PIC but are within the binary size. If you merge it into this branch it resolves the issue with VALUE clauses that I mentioned above. |
|
@GitMensch What is your take on this ? |
|
I need some more time to inspect this and the linked PR from @rbowler, but always keen to get comments from @ddeclerck as well :-) |
I don't really have anything to add ; I thought that PR was already ready for merge; cf your earlier comment:
|
This adds a test for COMP-5 binary size in presence of P.