由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - tail call strange behavior on cl.exe
相关主题
Do the two statements cost the same amount of time?Help: Another C++ compilation error on GCC
C++ optimization question[合集] a C++ template question (code inside)
瓶颈在哪儿?C++ question
用C++的写的numerical or optimization solver librarycopy constructor 问题
Looks like 王垠 was right about Google culture求GCC高手
在 windows下的C++开发平台是不是 Dev-C++?g++ default optimization error
About volatile in Copencv为什么不用java写???????
面试被问到G++和GCC编译器的关系Compiler
相关话题的讨论汇总
话题: int话题: return话题: sum话题: tail
进入Programming版参与讨论
1 (共1页)
i*****f
发帖数: 578
1
int f1(int n)
{
if (n<0) {
return 0;
}
return f(n-1) + 1;
}
int f2(int n, int sum)
{
if (n<0) {
return sum;
}
return f(n-1, sum+1);
}
if compiled w/o optimization, and run with n=0xffff, f2 gives a stack
overflow. f1 is good.
if compiled w/ optimization, both are ok.
cl.exe on Win7:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for
80x86
Not even see the stack overflow on Ubuntu 7.04+GCC w/o optimization.
b****j
发帖数: 78
2
1. each call of f1 uses less stack space than f2
2. default stack size set by cl might be different than gcc

【在 i*****f 的大作中提到】
: int f1(int n)
: {
: if (n<0) {
: return 0;
: }
: return f(n-1) + 1;
: }
: int f2(int n, int sum)
: {
: if (n<0) {

i*****f
发帖数: 578
3
right, just confirmed from the assembly that neither is tail call optimized.
Thanks!

【在 b****j 的大作中提到】
: 1. each call of f1 uses less stack space than f2
: 2. default stack size set by cl might be different than gcc

1 (共1页)
进入Programming版参与讨论
相关主题
CompilerLooks like 王垠 was right about Google culture
Eclipse JNI问题, 拜谢在 windows下的C++开发平台是不是 Dev-C++?
C++ Boost怎么样,好用吗?About volatile in C
看了这篇文章,脑子有点不够用了面试被问到G++和GCC编译器的关系
Do the two statements cost the same amount of time?Help: Another C++ compilation error on GCC
C++ optimization question[合集] a C++ template question (code inside)
瓶颈在哪儿?C++ question
用C++的写的numerical or optimization solver librarycopy constructor 问题
相关话题的讨论汇总
话题: int话题: return话题: sum话题: tail