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

[Sun C++] sizeof(mbstate_t) depends on #include order

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 4.2.0
    • 4.2.1
    • 21. Strings
    • None
    • Sun C++

    • Binary Incompatibility

    Description

      The size of the mbstate_t type and its aliiases (such as std::istream::traits_type::state_type)) appears to depend on the order in which stdcxx headers are #included:

      $ cat u.cpp && gmake u.o && mv u.o v.o && gmake CPPOPTS=-DMAIN u LDOPTS=v.o && ./u
      #ifdef MAIN
      
      #  include <iomanip>
      #  include <istream>
      
      void mbstate_size (size_t);
      
      int main ()
      {
          mbstate_size (sizeof (std::istream::traits_type::state_type));
      }
      
      #else
      #  include <assert.h>
      #  include <wchar.h>
      #  include <stdio.h>
      
      void mbstate_size (size_t n)
      {
          const size_t size = sizeof (mbstate_t);
      
          printf ("%zu == %zu\n", n, size);
          fflush (stdout);
          assert (n == size);
      }
      #endif
      CC -c -D_RWSTDDEBUG   -mt -I/amd/devco/sebor/stdcxx/include -I/build/sebor/stdcxx-suncc-5.9-j1-15D/include -I/amd/devco/sebor/stdcxx/tests/include  -library=%none -g  -m64 +w -errtags -erroff=hidef   u.cpp
      CC -c -D_RWSTDDEBUG   -mt -I/amd/devco/sebor/stdcxx/include -I/build/sebor/stdcxx-suncc-5.9-j1-15D/include -I/amd/devco/sebor/stdcxx/tests/include -DMAIN -library=%none -g  -m64 +w -errtags -erroff=hidef   u.cpp
      CC u.o -o u -L/build/sebor/stdcxx-suncc-5.9-j1-15D/rwtest -lrwtest15D -library=%none  -mt  -m64 -L/build/sebor/stdcxx-suncc-5.9-j1-15D/lib v.o -R/build/sebor/stdcxx-suncc-5.9-j1-15D/lib:/build/sebor/stdcxx-suncc-5.9-j1-15D/rwtest -lstd15D  -lm 
      24 == 32
      Assertion failed: n == size, file u.cpp, line 24
      Abort (core dumped)
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 2h Original Estimate - 2h
                  2h
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 3h
                  3h