Skip to Main Content
IBM Z Software


This portal is to open public enhancement requests against IBM Z Software products. To view all of your ideas submitted to IBM, create and manage groups of Ideas, or create an idea explicitly set to be either visible by all (public) or visible only to you and IBM (private), use the IBM Unified Ideas Portal (https://ideas.ibm.com).


Shape the future of IBM!

We invite you to shape the future of IBM, including product roadmaps, by submitting ideas that matter to you the most. Here's how it works:

Search existing ideas

Start by searching and reviewing ideas and requests to enhance a product or service. Take a look at ideas others have posted, and add a comment, vote, or subscribe to updates on them if they matter to you. If you can't find what you are looking for,

Post your ideas
  1. Post an idea.

  2. Get feedback from the IBM team and other customers to refine your idea.

  3. Follow the idea through the IBM Ideas process.


Specific links you will want to bookmark for future use

Welcome to the IBM Ideas Portal (https://www.ibm.com/ideas) - Use this site to find out additional information and details about the IBM Ideas process and statuses.

IBM Unified Ideas Portal (https://ideas.ibm.com) - Use this site to view all of your ideas, create new ideas for any IBM product, or search for ideas across all of IBM.

ideasibm@us.ibm.com - Use this email to suggest enhancements to the Ideas process or request help from IBM for submitting your Ideas.

Status Future consideration
Workspace COBOL Compilers
Created by Guest
Created on Jun 28, 2021

COBOL: Catch use of wrong index

Case: TS006008227
Summary: The COBOL compiler should warn when the wrong index is used

Details:

In COBOL the data division INDEXED BY phrase is used to associate an index with a table.
“A table without an INDEXED BY phrase can be referred to through indexing by using an
index-name associated with another table”, or by a USAGE IS INDEX field, or by subscripts.
You can also use another table's index-name even with tables that do have an INDEXED-BY PHRASE.

But there be dragons here. As the Language Reference warns:

An index-name can be used to reference any table. However, the element length of the table
being referenced and of the table that the index-name is associated with should match.
Otherwise, the reference will not be to the same table element in each table, and you might
get runtime errors.

No kidding. Use of the wrong index can result in difficult to find errors that range from
subtle to catastrophic. It generally corrupts your table data.

(This is because internally the index value is a displacement to the start of the OCCURS field.
If the stride of the table is different, indexes for the same subscript number have different
displacements.)

We think that the COBOL compiler should generate a warning if an INDEXED BY index-name is used
with a different table where the length of the OCCURS field is not the same. We can think of
few legitimate reasons for purposefully writing code this way, that couldn't be fixed by
redefining with an OCCURS entry that has a matching length.

It should not generate the warning if the index-name is defined with the same stride as the
table where it is being used. Nor should there be warnings related to use of USAGE IS INDEX
items, unless you think the optimizer can track data flow to the extent where it can determine
that such an item was created from a table with one stride but then used with a table with a
different stride. (We're not suggesting that it should go this far.)

If there is a belief that the warning should be suppressible, then it could be associated with
a compile option or via the RULES option. But our opinion is that it should just generate the
warning.

(Compare to such warnings as overlapping moves, which do have some legitimate reasons but still
generate the warning. I'd say that using the wrong index is more likely to be a mistake than an
overlapping move.)

Idea priority Medium
  • Guest
    Reply
    |
    Sep 16, 2021

    Hi, this feature might not possible all the time, but we should be able to do it for cases where we know the strides are fixed during compile time. We will accept this RFE for such fixed cases. This RFE will be updated further once put into plan. Thanks.

  • Guest
    Reply
    |
    Aug 4, 2021

    This RFE is being investigated further.

  • Guest
    Reply
    |
    Jun 29, 2021

    This is a dublicate of https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=134301
    :-)