IBM Support

PH18274: INCORRECT LOOP EXECUTION WHEN COMPILING WITH Z/OS COMPILER

A fix is available

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When going through the assembler code of the while loop
    condition, the problem is that the assignment is performed
    twice, so the first element of t is skipped. If t has more
    elements, the 1st, 3rd, etc. elements are skipped.
    
    The following test case demonstrates this issue:
    
    ===== COMPILE COMMAND:
    c++ test.cpp
    
    
    ===== TESTCASE:
    $cat test.cpp
    #include <stdio.h>
    int main()
    {
        int i = 0;
        const int t[2] = { 1 };
        while (const int x = t[i++])
       {
            printf("In loop: i=%d\n", i);
       }
       printf("After loop: i=%d\n", i);
    
      return 0;
    }
    $
    
    
    ===== ACTUAL OUTPUT:
    $./a.out
    After loop: i=2
    $
    
    
    
    ===== EXPECTED OUTPUT:
    $ ./a.out
    In loop: i=1
    After loop: i=2
    $
    

Local fix

  • N/A
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED: Users of the zosv2r4 C/C++ compiler          *
    ****************************************************************
    When going through the assembler code of the while loop
    condition, the problem is that the assignment is performed
    twice, so the first element of t is skipped. If it has more
    elements, the 1st, 3rd, etc. elements are skipped.
    

Problem conclusion

  • Apply service provided.
    

Temporary fix

Comments

APAR Information

  • APAR number

    PH18274

  • Reported component name

    C/C++ FOR MVS

  • Reported component ID

    56551210A

  • Reported release

    7C0

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2019-10-18

  • Closed date

    2019-10-18

  • Last modified date

    2021-09-01

  • APAR is sysrouted FROM one or more of the following:

    PH18051

  • APAR is sysrouted TO one or more of the following:

    PH40309

Modules/Macros

  • CCN$P00  CCN$P0X  CCNECICS CCNECWI  CCNED240 CCNEDSCT CCNEDWRT
    CCNEFILT CCNEHIFC CCNEIPA3 CCNEIPAO CCNEMDEP CCNEOPTP CCNEP
    CCNEPP   CCNETBY  CCNLMP00 CCNLMP01 CCNLMP02 CCNLMP03 CCNLMP04
    CCNLMP05 CCNLMP06 CCNLMP07 CCNLMP08 CCNLMP09 CCNLMP0A CCNLMP0B
    CCNLMP0C CCNLMP0D CCNLMP0E CCNLMP0F CCNLMP20 CCNLMP21 CCNLMP22
    CCNLMP23 CCNLMP24 CCNLMP25 CCNLMP26 CCNLMP27 CCNMSGE  CCNMSGT
    CCNPDF00 CCNPDF01 CCNPDF02 CCNPDF03 CCNPDF04 CCNPDF05 CCNPDF06
    CCNPDF07 CCNPDF08 CCNPDF09 CCNPDF0A CCNPDF0B CCNPDF0C CCNPDF0D
    CCNPDF0E CCNPDF0F CCNPDF10 CCNPDF11 CCNPDF12 CCNPDF13 CCNPDF14
    CCNPDF15 CCNPDF16 CCNPDF17 CCNPDF18 CCNPDF19 CCNPDF1A CCNPDF1B
    CCNPDF1C CCNPDF1D CCNPDF1E CCNPDF1F CCNPDF20 CCNPDF21 CCNPDF22
    CCNPDF23 CCNPDF24 CCNPDF25 CCNQIPA
    

Fix information

  • Fixed component name

    C/C++ FOR MVS

  • Fixed component ID

    56551210A

Applicable component levels

  • R7C0 PSY UI65848

       UP19/11/14 P F911

Fix is available

  • Select the PTF appropriate for your component level. You will be required to sign in. Distribution on physical media is not available in all countries.

[{"Line of Business":{"code":"LOB08","label":"Cognitive Systems"},"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSTLTF","label":"z\/OS XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"7C0"}]

Document Information

Modified date:
02 September 2021