]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix a problem that leads to a segfault at the end of the program with gcc3.4 and...
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 5 May 2003 13:49:06 +0000 (13:49 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 5 May 2003 13:49:06 +0000 (13:49 +0000)
git-svn-id: https://svn.dealii.org/trunk@7560 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/reference.cc
tests/lac/block_vector.cc

index 86a04515b9c9fc5445e62731d0811f67b2f9ce6f..114132dc0ec2b4f4cbbeddcf0ced4477dbe60f94 100644 (file)
@@ -40,7 +40,27 @@ int main()
   std::ofstream logfile("reference.output");
   deallog.attach(logfile);
   deallog.depth_console(0);
+
+                                   // we do something rather weird in
+                                   // this file: bind the buffer of
+                                   // cerr to the log file, so that
+                                   // the output of the Assert* macros
+                                   // that are written to std::cerr
+                                   // end up in the logfiles.
+                                   //
+                                   // so make sure we store a pointer
+                                   // to the old buffer, switch to the
+                                   // buffer of the logfile, and at
+                                   // the end of main() switch
+                                   // back. note that if we don't
+                                   // switch back, we get a segfault
+                                   // later on in the destruction of
+                                   // std::cerr, since it tries to do
+                                   // something with its buffer, but
+                                   // that is already gone by then
+  std::basic_streambuf<char> *old_cerr_buf = std::cerr.rdbuf();
   std::cerr.rdbuf(logfile.rdbuf());
+  
   Test a("A");
   const Test b("B");
   SmartPointer<Test>       r=&a;
@@ -71,5 +91,7 @@ int main()
     Test d("D");
     r = &d;
   }
+
+  std::cerr.rdbuf(old_cerr_buf);
 }
 
index 67c3a72e869b803b8c06f02a2ecab2df88b533b9..09ffa9953fb8976e2332a854ef1483a07347d809 100644 (file)
@@ -154,6 +154,10 @@ int main ()
   logfile.precision(3);
   deallog.attach(logfile);
   deallog.depth_console(0);
+
+                                   // do the same weird stuff as in
+                                   // tests/base/reference.cc
+  std::basic_streambuf<char> *old_cerr_buf = std::cerr.rdbuf();
   std::cerr.rdbuf(logfile.rdbuf());
   
   try
@@ -185,7 +189,6 @@ int main ()
       return 3;
     };
   
-  
-  return 0;
+  std::cerr.rdbuf(old_cerr_buf);
 }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.