g ++ 3.4异常问题 [英] g++ 3.4 exception problem
问题描述
我有一个案例,在类的构造函数中有一个带有
虚拟基础的异常导致终止:
struct vbase {};
struct foo:虚拟vbase {
foo(){
throw" foo ctor中的例外情况;;
}
};
main()
{
struct bar:public foo {};
尝试{
bar a;
}
catch(...){
}
返回0;
};
此程序演示了g ++ 3.4中的问题。该程序终止,而不是捕获异常的
。基本dtor被称为
预期,但是返回时,有一些生成的代码我不能解释为
,这会在bad_alloc +跳转到某些终止代码80.
这应该是一个线索...但我无法抓住它。
|
|在ieee dot org的markn
|
I have a case where an exception in the constructor of class with a
virtual base leads to termination:
struct vbase {};
struct foo : virtual vbase {
foo() {
throw "exception in foo ctor";
}
};
main()
{
struct bar : public foo {};
try {
bar a;
}
catch ( ... ) {
}
return 0;
};
This program demonstrates the problem in g++ 3.4. Instead of catching
the exception, the program terminates. The base dtor gets called as
expected, but upon return, there is some generated code that I can''t
decipher, which jumps to some termination code at bad_alloc + 80.
That should be a clue... but I''m unable to catch it.
|
| markn at ieee dot org
|
推荐答案
sn ******** @ gmail.com 写道:
sn********@gmail.com wrote:
我有一个例外情况具有
虚拟基础的类的构造函数导致终止:
struct vbase {};
struct foo:虚拟vbase {
foo() {
抛出'foo ctor中的例外';
}
};
main()
{
结构栏:public foo {};
尝试{
bar a;
}
catch(...){
}
返回0;
};
这个程序演示了g ++ 3.4中的问题。该程序终止,而不是捕获异常。基本dtor被称为
期望,但返回时,有一些生成的代码我无法解密,跳转到bad_alloc + 80的某些终止代码。
|
|在ieee dot org的markn
|
I have a case where an exception in the constructor of class with a
virtual base leads to termination:
struct vbase {};
struct foo : virtual vbase {
foo() {
throw "exception in foo ctor";
}
};
main()
{
struct bar : public foo {};
try {
bar a;
}
catch ( ... ) {
}
return 0;
};
This program demonstrates the problem in g++ 3.4. Instead of catching
the exception, the program terminates. The base dtor gets called as
expected, but upon return, there is some generated code that I can''t
decipher, which jumps to some termination code at bad_alloc + 80.
That should be a clue... but I''m unable to catch it.
|
| markn at ieee dot org
|
建议:尝试使用Gcc 4.0.1。版本3.4有时候看起来很奇怪,我认为从现在开始,这项工作将集中在版本4上。
Giancarlo。
Suggestion: try with Gcc 4.0.1. Ver 3.4 seems weird at times, and I think
the effort will be focused on version 4 from now on.
Giancarlo.
g ++ 4.0.0中出现同样的问题......我真的很想知道这是一个编译器问题还是我做某事错误......
Same problem appears in g++ 4.0.0... I''d really like to know whether
this is a compiler problem or me doing something wrong...
< sn ******** @ gmail.com>在消息中写道
news:11 ********************** @ g47g2000cwa.googlegr oups.com ...
<sn********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
我有一个案例,其中带有
虚拟基础的类构造函数中的异常导致终止:
#include< stdexcept>
struct vbase {};
struct foo:虚拟vbase {
foo(){
抛出foo ctor中的异常;
这不是你要抛出的异常对象。尝试:
抛出std :: exception(" foo ctor");
}
};
main()
int main()
{
struct bar:public foo {};
上面的结构栏类型定义超出了主体的范围。
尝试{
bar a;
}
catch(...)$
catch(const std :: exception& e)
{
e.what();
}
返回0;
};
此程序演示了g ++ 3.4。该程序终止,而不是捕获异常。基本dtor被称为
期望,但返回时,有一些生成的代码我无法解密,跳转到bad_alloc + 80的某些终止代码。
I have a case where an exception in the constructor of class with a
virtual base leads to termination:
#include <stdexcept>
struct vbase {};
struct foo : virtual vbase {
foo() {
throw "exception in foo ctor";
Thats not an exception object you are throwing. Try:
throw std::exception("foo ctor");
}
};
main()
int main()
{
struct bar : public foo {};
The struct bar type definition above goes outside of main''s body.
try {
bar a;
}
catch ( ... ) {
}
catch (const std::exception& e)
{
e.what();
}
return 0;
};
This program demonstrates the problem in g++ 3.4. Instead of catching
the exception, the program terminates. The base dtor gets called as
expected, but upon return, there is some generated code that I can''t
decipher, which jumps to some termination code at bad_alloc + 80.
That should be a clue... but I''m unable to catch it.
这篇关于g ++ 3.4异常问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!