Hi
I am confronted with a classical problem: a program gives correct
results when compiled with optimizations off, and gives the wrong ones
with optimization (-O2) on.
I have isolated the probem in a single file but now there is no way that
I can further track down the problem to one of the many functions in
that file.
I have in my small C compiler introduced the following construct:
#pragma optimize(on/off,push/pop)
to deal with optimizer bugs.
#pragma optimize(off)
turns OFF all optimizations until a #pragma optimize(on) is seen or
until the end of the compiulation unit. If
#pragma optimize(off,push)
is given, the optimization state can be retrieved with a
#pragma optimize(pop), or
#pragma optimize(on)
This has three advantages:
1) Allows the user to reduce the code area where the problem is hiding.
2) Provides a work around to the user for any optimizer bug.
3) Allows gcc developers to find bugs in a more direct fashion.
These pragmas can only be given at a global scope, not within a function.
I do not know gcc internals, and this improvement could be difficult to
implement, and I do not know either your priorities in gcc development
but it surely would help users. Obviously I think that the problem is in
the code I am compiling, not in gcc, but it *could* be in gcc. That
construct would help enormously.
Thanks in advance for your time.
jacob