[mapguide-trac] #317: Smart pointer methods in ptr.h throw nothing

MapGuide Open Source trac_mapguide at osgeo.org
Tue Nov 20 14:12:30 EST 2007


#317: Smart pointer methods in ptr.h throw nothing
--------------------------+-------------------------------------------------
   Reporter:  hugueswski  |       Owner:     
       Type:  defect      |      Status:  new
   Priority:  medium      |   Milestone:     
  Component:  Server      |     Version:     
   Severity:  major       |    Keywords:     
External_id:              |  
--------------------------+-------------------------------------------------
 The throw of nothing is causing some problems in a sevral methods, like
 this one:

 #ifdef _WIN32
     T** operator&() throw(...)
 #else
     T** operator&()
 #endif
     {
         if (p!=NULL)
             throw; //
 ::Create(MgException::NLSGetMessage(_NLSID(_2_BADPARAMETER)));
         return &p;
     }

 Notice that the throw statements are actually rethrow statements - these
 can't be caught by any catch statement.
 Here is a little test app showing that you can't catch this kind of throw
 statement even with catch(…). You always crash with an unhandled
 exception.

 void f() throw(...)
 {
         throw;
 }


 int main(int, char **)
 {
         try
         {
                 f();
         }
         catch(...)
         {
                 ::std::cerr << "Caught an exception" << ::std::endl;
         }
         return 1;
 }

-- 
Ticket URL: <http://trac.osgeo.org/mapguide/ticket/317>
MapGuide Open Source <http://mapguide.osgeo.org/>
MapGuide Open Source Internals


More information about the mapguide-trac mailing list