www.digitalmars.com         C & C++   DMDScript  

c++ - function-level try blocks unsupported

reply "Laurentiu Pancescu" <user domain.invalid> writes:
DMC doesn't seem to support function-level try blocks, as ISO-C++ says (try
to compile code below).  I tried with BCC 5.5.1 (which makes a big fuss with
its "full" <g> ANSI compliance), and it's not supported, either.  It works
fine with GCC 2.95.2 or later...

For the curious: BCC says "Test::Test() declared outside its class".  Oh
well...  :)

Laurentiu

//-------------------------------------------------
class Thrower
{
    public:
    Thrower() throw(int);
};

Thrower::Thrower() throw(int) { throw 1; }

class Test
{
    public:
        Test() throw (int);
    private:
        Thrower t;
};

Test::Test() throw(int)
try
:t()
{

}
catch(int x)
{
    throw x+1;
}
Mar 17 2002
parent "Walter" <walter digitalmars.com> writes:
I've never encountered that before! Thanks for reporting it.

"Laurentiu Pancescu" <user domain.invalid> wrote in message
news:a72bjl$1dd$1 digitaldaemon.com...
 DMC doesn't seem to support function-level try blocks, as ISO-C++ says
(try
 to compile code below).  I tried with BCC 5.5.1 (which makes a big fuss
with
 its "full" <g> ANSI compliance), and it's not supported, either.  It works
 fine with GCC 2.95.2 or later...

 For the curious: BCC says "Test::Test() declared outside its class".  Oh
 well...  :)

 Laurentiu

 //-------------------------------------------------
 class Thrower
 {
     public:
     Thrower() throw(int);
 };

 Thrower::Thrower() throw(int) { throw 1; }

 class Test
 {
     public:
         Test() throw (int);
     private:
         Thrower t;
 };

 Test::Test() throw(int)
 try
 :t()
 {

 }
 catch(int x)
 {
     throw x+1;
 }
Mar 17 2002