IBM Support

LI77963: XLC REJECTS ARRAY INITIALIZATION

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as program error.

Error description

  • The xlc compiler incorrectly produces an error message for the
    provided test case.
    
    ===== COMPILE COMMAND:
    xlc -c xlc-anon-struct.c
    
    ===== TESTCASE:
    $ cat  xlc-anon-struct.c
    
    struct foo { float *a; char c; };
    
    
    void bar(int *x)
    {
    }
    
    
    void baz(struct foo *x)
    {
    }
    
    
    int main(void)
    {
      int i = 42;
      float x = 42.0f;
      struct foo a = { .a = &x, .c = 'f' };
      bar((int []){i});
      baz((struct foo[]){a});
    }
    $
    ===== ACTUAL OUTPUT:
    
    $xlc -c xlc-anon-struct.c
    "xlc-anon-struct.c", line 17.22: 1506-196 (S) Initialization
    between types "float*" and "struct foo" is not allowed.
    $
    ===== EXPECTED OUTPUT:
    Clean compile
    

Local fix

  • As a workaround, if the line:
    baz((struct foo[]){a});
    is replaced with:
    baz((struct foo[]){{.a = &x, .c = 'f'}});
    it compiles clean.
    

Problem summary

  • USERS AFFECTED:
    Users who wish to put non literal expressions in a curly braced
    initialiser list for arrays of structs and unions may be
    affected by this issue.
    
    PROBLEM DESCRIPTION:
    The compiler is only accepting literal and compound literal
    expressions in curly braced array initialiser lists for arrays
    of structs and unions.
    

Problem conclusion

  • Changed the compiler to accept expressions other than compound
    literal expressions, as long as they are of the correct type.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI77963

  • Reported component name

    XL C/C++ FOR LI

  • Reported component ID

    5725C7300

  • Reported release

    C10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2014-04-30

  • Closed date

    2014-04-30

  • Last modified date

    2014-04-30

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

    IV55636

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

Fix information

  • Fixed component name

    XL C/C++ FOR LI

  • Fixed component ID

    5725C7300

Applicable component levels

  • RC10 PSY

       UP



Document information

More support for: XL C/C++ for Linux
Compiler

Software version: 12.1

Reference #: LI77963

Modified date: 30 April 2014