Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: Exception S...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 8 Topic 9569 of 9807
Post > Topic >>

Re: Exception Specifications

by Francis Glassborow <francis.glassborow@[EMAIL PROTECTED] > May 3, 2008 at 04:10 PM

Jon wrote:
> On May 2, 4:43 am, Keith Halligan <keith.halli...@[EMAIL PROTECTED]
> wrote:
>> I'm a bit unsure about the following behaviour with exception
>> specifiers in C++ functions
>>
>> Here's some sample code:
>>
>> #include <exception>
>>
>> class Sy***ception { };
>>
>> void f( ) throw (Sy***ception)
>> {
>>     throw std::exception();
>>
>> }
> 
> I may be wrong, but I believe that this code should fail to compile.
> The exception specification for f() indicates that it will throw
> objects only of type Sy***ception.  class Sy***ception is not derived
> from std::exception so throwing an object of class std::exception
> would violate the exception specification.
> 

No, the compiler should compile it because there is no error until f()
is called, and even then there is a well-defined action to be carried
out (call unexpected()) and so the code is still not erroneous.


-- 
Note that robinton.demon.co.uk addresses are no longer valid.

      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 8 Posts in Topic:
Exception Specifications
Keith Halligan <keith.  2008-05-02 04:43:30 
Re: Exception Specifications
Martin T <0xCDCDCDCD@[  2008-05-02 12:48:22 
Re: Exception Specifications
peter koch larsen <pet  2008-05-02 12:46:50 
Re: Exception Specifications
Francis Glassborow <fr  2008-05-02 12:46:16 
Re: Exception Specifications
Jon <j.trauntvein@[EMA  2008-05-02 12:47:05 
Re: Exception Specifications
gnuyuva <gnuyuva@[EMAI  2008-05-02 12:51:23 
Re: Exception Specifications
Greg Herlihy <greghe@[  2008-05-03 06:13:28 
Re: Exception Specifications
Francis Glassborow <fr  2008-05-03 16:10:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 19 20:02:41 CDT 2008.