C++ Standard Library
  1. C++ Standard Library
  2. STDCXX-843

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 4.2.0
    • Fix Version/s: 4.2.1
    • Component/s: 21. Strings
    • Labels:
      None
    • Environment:

      Sun C++

    • Severity:
      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)
      

        Issue Links

          Activity

          Martin Sebor logged work - 09/Apr/08 00:10
          • Time Spent:
            2h
             
            Fixed.
          Martin Sebor created issue -
          Martin Sebor made changes -
          Field Original Value New Value
          Link This issue incorporates STDCXX-826 [ STDCXX-826 ]
          Hide
          Martin Sebor added a comment -

          Fix committed in r646133.
          Need to put together a regression test.
          Will close after the fix along with the regression test have been integrated into 4.2.x in the next bulk merge.

          Show
          Martin Sebor added a comment - Fix committed in r646133 . Need to put together a regression test. Will close after the fix along with the regression test have been integrated into 4.2.x in the next bulk merge.
          Martin Sebor made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          Farid Zaripov added a comment -
          Show
          Farid Zaripov added a comment - Merged in 4.2.x branch thus: http://svn.apache.org/viewvc?view=rev&revision=648752
          Hide
          Martin Sebor added a comment -

          Regression test committed in r662614.

          Show
          Martin Sebor added a comment - Regression test committed in r662614 .
          Martin Sebor made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Martin Sebor made changes -
          Time Spent 2h [ 7200 ]
          Remaining Estimate 2h [ 7200 ] 0h [ 0 ]
          Martin Sebor logged work - 03/Jun/08 02:11
          • Time Spent:
            1h
             
            Added a regression test.
          Martin Sebor made changes -
          Time Spent 2h [ 7200 ] 3h [ 10800 ]

            People

            • Assignee:
              Martin Sebor
              Reporter:
              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

                  Development