Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-163

ios_base data member layout wastes 2 bytes

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 4.1.2, 4.1.3, 4.1.4, 4.2.0
    • 5.0.0
    • 27. Input/Output
    • None
    • all

    • Inefficiency

    Description

      The latest HP aCC beta points out a space inefficiency in the definition of the ios_base class. The next time we break binary compatibility we should rearrange the data mebers to avoid the wasted space.

      aCC -c -D_RWSTD_USE_CONFIG -I/build/sebor/aCC-6.07-8s/include -I/build/sebor/dev/stdlib/include -AA +O2 +w +wlint +W392 +W655 +W684 +W818 +W819 +W849 +W2193 +W2236 +W2261 +W2340 +W2401 +W2487 +W4255 /build/sebor/dev/stdlib/src/iostream.cpp
      "/build/sebor/dev/stdlib/include/rw/_iosbase.h", line 357: remark #4227-D:
      padding struct with 2 bytes to align member "_C_usr"
      _C_usr_data *_C_usr; // user data (iword, pword, callbacks)
      ^

      $ cat -n /build/sebor/dev/stdlib/include/rw/_iosbase.h | head -n 360 | tail -n 33
      328 void *_C_rdbuf; // pointer to the associated stream buffer
      329 _RWSTD_STREAMSIZE _C_prec; // current precision
      330 _RWSTD_STREAMSIZE _C_wide; // current width
      331 unsigned _C_fmtfl; // formatting flags
      332 unsigned char _C_state; // stream state
      333 unsigned char _C_except; // active exceptions
      334
      335 static bool _C_sync_with_stdio;
      336
      337 private:
      338
      339 ios_base (const ios_base&); // not defined
      340 ios_base& operator= (const ios_base&); // not defined
      341
      342 #if _EDG_VERSION_ < 245
      343
      344 // working around an EDG eccp 2.3x bug (also derivatives,
      345 // such as MIPSpro, see PR #28631)
      346 public:
      347 struct _C_usr_data;
      348
      349 #else
      350
      351 protected:
      352 struct _C_usr_data;
      353
      354 #endif // EDG < 2.45
      355
      356 protected:
      357 _C_usr_data *_C_usr; // user data (iword, pword, callbacks)
      358 locale _C_loc; // locale associated with stream
      359
      360 friend struct _RWSTD_EXPORT Init;

      Attachments

        Activity

          People

            Unassigned Unassigned
            sebor Martin Sebor
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: