Skip to content

Conversation

@rbowler
Copy link

@rbowler rbowler commented Oct 14, 2025

Pull Request: comp-5-uses-binary-byteorder dialect configuration option

Summary

This branch adds a new dialect configuration option which allows COMP-5 fields to be processed using the same byte order as BINARY fields.

Motivation

Previously GnuCOBOL always stored COMP-5 fields using native endianness, as opposed to BINARY or COMP fields which are held in either big-endian or native format depending on the binary-byteorder configuration option. However, COBOL programs ported from the mainframe expect COMP-5 fields to be stored in big-endian format like BINARY fields, the difference between COMP-5 and BINARY being that COMP-5 fields are always treated as no-trunc regardless of the setting of the binary-truncate option. The new configuration option allows the user to request that COMP-5 fields should be stored using the same endianness as BINARY fields.

Changes

  • Added configuration option comp-5-uses-binary-byteorder to config.def
  • Updated all dialect config files to include the statement comp-5-uses-binary-byteorder: no
  • Modified field.c to set the the flag_binary_swap flag for COMP-5 fields when:
    -- the comp-5-uses-binary-byteorder option is activated
    -- binary-byteorder=big-endian is specified
    -- the host architecture is little-endian
  • Updated test case configuration.at to check that all dialect config files contain the new option
  • Added a new test case COMP-5 byteorder in data_binary.at to verify correct behavior both with and without the new configuration option when binary-byteorder=big-endian is specified on little-endian systems.

Impact

  • This change also affects BINARY-SHORT, BINARY-LONG, and BINARY-DOUBLE which GnuCOBOL treats internally as COMP-5.
  • Existing programs compiled with comp-5-uses-binary-byteorder: no will continue to operate unchanged.

Testing

  • All existing test suites have been run on x86 (little-endian) architecture.
  • The new test case produces expected results on x86.

Related Issues / Discussion

  • It may be considered desirable to update ibm-strict.config to set comp-5-uses-binary-byteorder: yes if that can be done without impacting existing programs.
  • This change is compatible with Add COMP-5 binary size test #197

Please review and provide feedback or suggestions.

@rbowler
Copy link
Author

rbowler commented Oct 22, 2025

@GitMensch may I request a review of this pull request? Thanks.

@GitMensch GitMensch changed the base branch from gcos4gnucobol-3.x to gitside-gnucobol-3.x December 16, 2025 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant