ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
[boost] Patch for the Function library
by Guillaume Melquiond other posts by this author
May 18 2003 3:30PM messages near this date
RE: [boost] Patches for Borland's free compiler | Re: [boost] Patch for the Function library
According to the paragraph 3.7.3.1-3 of the Standard, an 'operator new'
can return a null pointer or throw an exception to report a failed
allocation; but it isn't allowed to adopt the two behaviors.
Unfortunately, it's exactly what 'stateless_integer_add' does for the sake
of avoiding warnings; and gcc complains about it. So the line
"return 0; // suppress warnings is wrong." doesn't do what it's supposed
to do: it doesn't suppress warnings. Here is patch that returns another
pointer so that gcc doesn't complain. I'm not sure it's the best way to
choose a non-null pointer, but at least gcc doesn't complain anymore, and
the compilers that needed a return statement still have it.


Index: libs/function/test/stateless_test.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/function/test/stateless_test.cpp,v
retrieving revision 1.6
diff -u -r1.6 stateless_test.cpp
--- libs/function/test/stateless_test.cpp       30 Jan 2003 14:25:00 -0000     1.6
+++ libs/function/test/stateless_test.cpp       18 May 2003 15:25:01 -0000
@@ -24,7 +24,7 @@
   void* operator new(std::size_t, stateless_integer_add*)
   {
     throw std::runtime_error("Cannot allocate a stateless_integer_add");
-    return 0; // suppress warnings
+    return (void*)1; // suppress warnings
   }

   void operator delete(void*, stateless_integer_add*) throw()


Regards,

Guillaume

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Guillaume Melquiond
Douglas Gregor
Giovanni Bajo
Guillaume Melquiond
Giovanni Bajo
Guillaume Melquiond
Giovanni Bajo
Guillaume Melquiond
Beman Dawes

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved