I've got an unexpected crash when throwing an
exception. I've created a test progam below. I
believe it's a problem in GCC4 as a program
compiled with GCC3 has similar code that works
as expected.
#include
#include
#include "swis.h"
using namespace std;
class OsError
{
_kernel_oserror *_err;
public:
OsError(_kernel_oserror *err) : _err(err) {};
};
inline void swix_check(_kernel_oserror *err)
{
if (err != 0)
{
cout << "Throwing error " << err->errmess << endl;
throw OsError(err);
}
}
string canonicalise(string pathname)
{
printf("in canon\n");
// Calculate required buffer size.
unsigned int size=0;
_kernel_swi_regs regs;
_kernel_oserror *err;
regs.r[0] = 37;
regs.r[1]= (int)pathname.c_str();
regs.r[2] =0;
regs.r[3] =0;
regs.r[4] =0;
regs.r[5] = size;
printf("pre call\n");
swix_check( _kernel_swi(OS_FSControl, ®s, ®s));
printf("post call err = %p\n", err);
size = regs.r[5];
size=1-size;
printf("size is %d\n", size);
// Canonicalise pathname.
char buffer[size];
regs.r[0] = 37;
regs.r[1]= (int)pathname.c_str();
regs.r[2] =(int)buffer;
regs.r[3] =0;
regs.r[4] =0;
regs.r[5] = size;
printf("pre call\n");
err = _kernel_swi(OS_FSControl, ®s, ®s);
printf("post call err = %p\n", err);
printf("pre return\n");
return string(buffer);
}
int main(int argc, char *argv[])
{
string test("");
try
{
string result = canonicalise(test);
cout << "Test value " << test << endl;
cout << "Result " << result << endl;
} catch(OsError &err)
{
cout << "Got OS Error as expected\n" << endl;
}
}
The version of the cross-compiler I'm using was
built at the end of June. I couldn't see any
changes that looked like they should make a
difference since then though.
Regards,
Alan
_________________________________________________________________
Access your other email accounts and manage all your email from one place.
http://clk.atdmt.com/UKM/go/167688463/direct/01/
_______________________________________________
GCCSDK mailing list [email protected]
Bugzilla: http://www.riscos.info/bugzilla/index.cgi
List Info: http://www.riscos.info/mailman/listinfo/gcc
Main Page: http://www.riscos.info/index.php/GCCSDK