IBM Support

LI72866: I/O stream manipulation problem

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Compilation fails with a severe message when doing stream
    manipulation inside a local struct's function.
    e.g.:
    $ cat get_msg.cpp
    #include <iostream>
    #include <fstream>
    #include <iomanip>
    
    int notmain () {
    #ifdef _POS1
      // THIS will cause the problem
      std::ofstream os;
    #endif
      struct S {
        void f () {
    #ifdef _POS2
          // THIS WILL
          std::ofstream os;
    #endif
          std::cout << std::setw(4) << 666 << std::endl;
    #ifdef _POS3
          // THIS WILL
          std::ofstream os;
    #endif
        }
      };
    #ifndef _POS1
    #ifndef _POS2
    #ifndef _POS3
      // THIS will NOT cause the problem
      //std::ofstream os;
    #endif
    #endif
    #endif
      return 0;
    }
    $ xlC_r -D_POS1 -c get_msg.cpp
    "get_msg.cpp", line 20.20: 1540-0253 (S) This use of undefined
    class "std::_Smanip" is not valid.
    $ xlC_r -D_POS2 -c get_msg.cpp
    "get_msg.cpp", line 20.20: 1540-0253 (S) This use of undefined
    class "std::_Smanip" is not valid.
    $ xlC_r -D_POS3 -c get_msg.cpp
    "get_msg.cpp", line 20.20: 1540-0253 (S) This use of undefined
    class "std::_Smanip" is not valid.
    $ xlC_r -c get_msg.cpp
    $
    

Local fix

  • Adding this declaration of std::_Smanip before the function with
    the local class (notmain in the example) will resolve the
    problem:
    template struct std::_Smanip<int>;
    

Problem summary

  • Due to a compiler defect, the required instantiation
    might happen too late causing compiler errors.
    
    The user would see either an invalid error message for invalid
    use of an incomplete or undefined class OR there might be an
    internal compiler error.
    

Problem conclusion

  • The compiler now correctly handles implicit instantiations
    requested while processing local classes.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI72866

  • Reported component name

    XLC/C++ RHEL4

  • Reported component ID

    5724M1610

  • Reported release

    800

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2007-12-13

  • Closed date

    2007-12-13

  • Last modified date

    2007-12-13

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

    IY99901

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

Fix information

  • Fixed component name

    XLC/C++ RHEL4

  • Fixed component ID

    5724M1610

Applicable component levels

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

Document Information

Modified date:
16 October 2021