www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - function-level try blocks unsupported

↑ ↓ ← "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
↑ ↓ → "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

 to compile code below).  I tried with BCC 5.5.1 (which makes a big fuss

 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