gcc forgets to decrease esp after function call

Vladimir Simonov Vladimir.Simonov@acronis.com
Thu Mar 15 11:37:00 GMT 2007


Andrew Haley wrote:
> Vladimir Simonov writes:
>  > The attached test case can be built by compile.sh.
>  > It produces two binaries - test_bin_bad & test_bin_good.
>  > 
>  > test_bin_good prints "Hello word" before exit.
>  > test_bin_bad crashes.
>  > 
>  > The difference is the only -O2 used while test_bin_bad build.
>  > 
>  > The symptoms are the same - incorrect esp usage in caller
>  > after call function returning object.
>  > 
>  > We reproduced the bug in gcc 4.1.0/4.1.1/4.1.2
>  > gcc 3.x can't compile the sources.
> 
> OK, we're getting closer. 

Hi

Are you capable to reproduce the bug?

> Unfortunately, your test case includes a
> ton of system headers for one particular system/version of gcc, 
But it doesn't contain any #include directive.
It is self consistent.

Do you mean that I should
add "#include" for system headers?
I think this way we may made the bug less obvious.

> and it
> also includes a lot of library code not used in your test case.

I understood it from the start of discussion :)
I hoped:
1. GCC delelopers have some tools or methods
to automatically remove text which does not affect
codegeneration. Or some compile stage which contans
intermediate data without unused by codegeneration
prototypes, classes, etc.
2. GCC developers are smart enough to localize and try
to fix gcc having such obvious indication as this -
codegenerator "forgets" that it called function returning
object. Is it impossible to find thin place/places taking
into account above, fix it and check by our test?
In such a case the test size has no defference in my opinion.


> Fillet that, and you will have a test case that can be submitted.
> 

It requires a lot of mannual work - remove a
peace of code, then check that the test can be built,
the check that the bug did not disappear, etc.

We'll try.

Regards
Vladimir



More information about the Gcc-help mailing list