Zachary Washburn
Zachary Washburn

Reputation: 11

Open-COBOL Uknown seg fault

I've been trying to teach myself COBOL. While attempting to do this i've run into an issue I can't figure out.

I'm running ubuntu 16.04, and using GnuCOBOL (Open-COBOL) to compile. I thought this may have been an issue with the Open-COBOL version from the repository so I have compiled from source, and receive the same issue.

When trying to run this code:

IDENTIFICATION DIVISION.
PROGRAM-ID. Multi.

DATA DIVISION.
WORKING-STORAGE SECTION.
*> Group Value
   01 VALS.
*> Elementary Value
      05 VAL-1 PIC 9(03) VALUE 4.
      05 VAL-2 PIC 9(03) VALUE 3.
      05 RESULT PIC 9(06).


PROCEDURE DIVISION.
   MULTIPLY VAL-1 BY VAL-2 GIVING RESULT.
   DISPLAY "Result is =" RESULT.
   DISPLAY 'GROUP DATA ITEM = ' VALS.

I receive:

Segmentation fault (core dumped)

I compiled with:

cobc -free -o Multi.o ./Multi.cob

I can't seem to figure out what I did wrong, and what causes the seg fault. Any ideas? Thanks in advance!

Upvotes: 1

Views: 830

Answers (1)

Edward H
Edward H

Reputation: 586

From your comment, it looks like you've mistaken the module Multi.o as an executable. The way to run the program Multi from the module is cobcrun Multi.

Alternatively, you can create a normal executable using cobc -x.

Upvotes: 5

Related Questions