IBM Support

IV55636: 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

    IV55636

  • Reported component name

    XL C FOR AIX

  • Reported component ID

    5725C7100

  • Reported release

    C10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2014-02-19

  • Closed date

    2014-07-18

  • Last modified date

    2014-07-18

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

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

    LI77963

Fix information

  • Fixed component name

    XL C FOR AIX

  • Fixed component ID

    5725C7100

Applicable component levels

[{"Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSGH2K","label":"XL C for AIX"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"12.1"}]

Document Information

Modified date:
03 October 2021