stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stele...@apache.org
Subject svn commit: r1379520 - in /stdcxx/branches/4.3.x: src/iostore.cpp tests/regress/27.basic_ios.copyfmt.stdcxx-1058.cpp
Date Fri, 31 Aug 2012 17:35:23 GMT
Author: steleman
Date: Fri Aug 31 17:35:23 2012
New Revision: 1379520

URL: http://svn.apache.org/viewvc?rev=1379520&view=rev
Log:
STDCXX-1058
* src/iostore.cpp (_C_copyfmt):
_C_usr->_C_iarray, _C_usr->_C_isize, _C_usr->_C_parray, _C_usr->_C_psize,
_C_usr->_C_cbarray, _C_usr->_C_cbsize set to zero after deletion.
* tests/regress/27.basic_ios.copyfmt.stdcxx-1058.cpp: added regression test.

Added:
    stdcxx/branches/4.3.x/tests/regress/27.basic_ios.copyfmt.stdcxx-1058.cpp   (with props)
Modified:
    stdcxx/branches/4.3.x/src/iostore.cpp

Modified: stdcxx/branches/4.3.x/src/iostore.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/src/iostore.cpp?rev=1379520&r1=1379519&r2=1379520&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/src/iostore.cpp (original)
+++ stdcxx/branches/4.3.x/src/iostore.cpp Fri Aug 31 17:35:23 2012
@@ -335,8 +335,14 @@ _C_copyfmt (const ios_base &rhs, void *d
             // delete existing arrays, if any; _C_usr will only be deleted
             // if `rhs' contains no user data (see below)
             operator delete (_C_usr->_C_iarray);
+            _C_usr->_C_iarray = 0;
+            _C_usr->_C_isize = 0;
             operator delete (_C_usr->_C_parray);
+            _C_usr->_C_parray = 0;
+            _C_usr->_C_psize = 0;
             operator delete (_C_usr->_C_cbarray);
+            _C_usr->_C_cbarray = 0;
+            _C_usr->_C_cbsize = 0;
         }
         else if (ia || pa || cba || ptie) {
             // allocation may throw

Added: stdcxx/branches/4.3.x/tests/regress/27.basic_ios.copyfmt.stdcxx-1058.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/regress/27.basic_ios.copyfmt.stdcxx-1058.cpp?rev=1379520&view=auto
==============================================================================
--- stdcxx/branches/4.3.x/tests/regress/27.basic_ios.copyfmt.stdcxx-1058.cpp (added)
+++ stdcxx/branches/4.3.x/tests/regress/27.basic_ios.copyfmt.stdcxx-1058.cpp Fri Aug 31 17:35:23
2012
@@ -0,0 +1,101 @@
+/**************************************************************************
+ *
+ * 27.basic_ios.copyfmt.stdcxx-1058.cpp - regression test for STDCXX-1058
+ *
+ * http://issues.apache.org/jira/browse/STDCXX-1058
+ *
+ * $Id$
+ *
+ **************************************************************************
+ *
+ * Licensed to the Apache Software  Foundation (ASF) under one or more
+ * contributor  license agreements.  See  the NOTICE  file distributed
+ * with  this  work  for  additional information  regarding  copyright
+ * ownership.   The ASF  licenses this  file to  you under  the Apache
+ * License, Version  2.0 (the  "License"); you may  not use  this file
+ * except in  compliance with the License.   You may obtain  a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the  License is distributed on an  "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY  KIND, either  express or
+ * implied.   See  the License  for  the  specific language  governing
+ * permissions and limitations under the License.
+ *
+ **************************************************************************/
+/*
+ * This program should run to completion and exit with return status 0
+ */
+
+#include <ios>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define TEST_ASSERT(expr) \
+    (expr) ? ret = 0 \
+    : fprintf(stderr,"file %s line %i: Assertion failed: %s\n", \
+    __FILE__, __LINE__, #expr); fflush(stderr); if (ret != 0) abort()
+
+int x;
+
+void testfun (std::ios_base::event ev, std::ios_base& iosobj, int index)
+{
+    x = index;
+
+    switch (ev)
+    {
+        case std::ios_base::copyfmt_event:
+            (void) fprintf(stderr, "copyfmt_event\n"); break;
+        case std::ios_base::imbue_event:
+            (void) fprintf(stderr, "imbue_event\n"); break;
+        case std::ios_base::erase_event:
+            (void) fprintf(stderr, "erase_event\n"); break;
+        default:
+            (void) fprintf(stderr, "unknown (this should never happen)\n"); break;
+    }
+}
+
+
+int main ()
+{
+    struct A: std::streambuf { };
+
+    struct B: std::ios {
+        A sb;
+        B () { init (&sb); }
+    } f0, f1;
+
+    int i = 101;
+    int ret = 1;
+
+    std::ios_base::event_callback e1 = &testfun;
+    f0.register_callback (e1, i);
+
+    x = 0;
+    f0.imbue (f0.getloc());
+    TEST_ASSERT (x == i);
+
+    x = 0;
+    ret = 1;
+    f0.copyfmt (f1);
+    TEST_ASSERT (x == i);
+
+	B s0, s1;
+
+	s0.register_callback (e1, i);
+
+	x = 0;
+	ret = 1;
+	s0.imbue (f0.getloc ());
+	TEST_ASSERT (x == i);
+
+	x = 0;
+	ret = 1;
+	s0.copyfmt (s1);
+	TEST_ASSERT (x == i);
+
+    return ret;
+}
+

Propchange: stdcxx/branches/4.3.x/tests/regress/27.basic_ios.copyfmt.stdcxx-1058.cpp
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message