[Bug cobol/126616] cobol: SIGSEGV in libgcobol.cc: binary_to_native_binary

"rdubner at gcc dot gnu.org via Gcc-bugs" <[email protected]> Mon, 03 Aug 2026 18:54:01 +0000
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D126616

--- Comment #1 from Robert Dubner <rdubner at gcc dot gnu.org> ---
I need more information.

I _always_ need enough to code to duplicate the error.  Otherwise, I have
absolutely no idea if a change to the source code addresses your problem.

And in this case, I need more context.=20=20

Is the `errno` mentioned in the report supposed to be the same as the system
error code defined in <errno.h>?

I wrote this version:
~~~~~~~~~~
        program-id.                 prog.
        data                        division.
        working-storage             section.
        77 errno                    USAGE BINARY-LONG EXTERNAL.
        procedure                   division.
            goback.
~~~~~~~~~~

It fails with=20

Floating point exception (core dumped)

Why the difference between yours and mine, I can't tell you.  I do know that
the only way I can create or access an EXTERNAL variable is essentially by
creating an explicit declaration for it.=20=20

The information in the documentation for errno(3) states

~~~~~~~~~~
errno is defined by the ISO C standard to be a modifiable lvalue
       of type int, and must not be explicitly declared; errno may be a
       macro.  errno is thread-local; setting it in one thread does not
       affect its value in any other thread.
~~~~~~~~~~

In other words:  It may not be possible for a COBOL program to access the
"errno.h" "errno" directly, and it may be necessary for an external "C"
function to provide that access.  And, consequently, it may be necessary to
forbid the use, in a COBOL program of an EXTERNAL named "errno".=