回来时崩溃 [英] crash on return
问题描述
在我的程序中有一个返回void的函数。
调用函数返回一个int。
没有编译器警告或错误。
它在线路返回1崩溃;
int caller();
{
做东西;
otherfunc(a,b);
返回1; < - 崩溃在这里
}
int caller();
void otherfunc(int int_a,int int_b);
我可以研究哪些问题?
谢谢
dave写道:< blockquote class =post_quotes>在我的程序中有一个返回void的函数。
调用函数返回一个int。
没有编译器警告或错误。
它在行返回1时崩溃;
int caller();
{
做东西;
otherfunc(a,b);
返回1; < - 在这里崩溃
}
int caller();
void otherfunc(int int_a,int int_b);
有什么问题我可以查看吗?
谢谢
定义崩溃。你能发一个最小但完整的例子,
证明了这个问题吗?奇怪的崩溃通常是任意指针的结果。在做东西中寻找它们或者otherfunc。
干杯! --M
dave写道:在我的程序中有一个返回空的函数。
调用函数返回一个int。
没有编译器警告或错误。
它在行返回1崩溃;
int caller();
{
otherfunc(a,b);
返回1; < - 在这里崩溃
}
int caller();
void otherfunc(int int_a,int int_b);
有什么问题我可以看一下吗?
首先,你可以考虑发布实际代码。那就是如果你想要我们为你的代码提供建议。如果你不在乎,你可以看看内存超支。
V
dave写道:在我的程序中有一个返回void的函数。
调用函数返回一个int。
没有编译器警告或错误。
它在线路返回1崩溃;
int caller();
做东西;
otherfunc( a,b);
返回1; < - 在这里崩溃
}
int caller();
void otherfunc(int int_a,int int_b);
有什么问题我可以看看吗?
谢谢
您的任何代码是否都使用堆栈指针?
Have a function in my program that returns a void.
The calling function returns an int.
No compiler warnings or errors.
It crashes on line return 1;
int caller();
{
do stuff;
otherfunc(a,b);
return 1; <- crashes here
}
int caller();
void otherfunc(int int_a,int int_b);
what are some issues I could look into?
thanks
dave wrote:Have a function in my program that returns a void.
The calling function returns an int.
No compiler warnings or errors.
It crashes on line return 1;
int caller();
{
do stuff;
otherfunc(a,b);
return 1; <- crashes here
}
int caller();
void otherfunc(int int_a,int int_b);
what are some issues I could look into?
thanks
Define "crashes". Can you post a minimal but complete example that
demonstrates the problem? Strange crashes are often the result of
wayward pointers. Look for them in "do stuff" or "otherfunc".
Cheers! --M
dave wrote:Have a function in my program that returns a void.
The calling function returns an int.
No compiler warnings or errors.
It crashes on line return 1;
int caller();
{
do stuff;
otherfunc(a,b);
return 1; <- crashes here
}
int caller();
void otherfunc(int int_a,int int_b);
what are some issues I could look into?
First and foremost, you could look into posting real code. That is if you
want us to advise you on your code. If you don''t care about that, you
could look into memory overruns.
V
dave wrote:Have a function in my program that returns a void.
The calling function returns an int.
No compiler warnings or errors.
It crashes on line return 1;
int caller();
{
do stuff;
otherfunc(a,b);
return 1; <- crashes here
}
int caller();
void otherfunc(int int_a,int int_b);
what are some issues I could look into?
thanks
Does any of your code play with the stack pointer?
这篇关于回来时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!