https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99797

--- Comment #11 from Martin Uecker <muecker at gwdg dot de> ---
(In reply to Ivan Sorokin from comment #10)

...
> > is a bug if this choice is unreasonable and does not serve its users well.
> 
> Do you have some specific proposal in mind?
> 
> Currently a user has these 5 options:
> 1. Using -O0 suppressing optimizations.
> 2. Using -fno-tree-ccp suppressing this specific optimization.

Optimizations are important, so this is not really an option.

> 3. Using -Wall and relying on warnings.

It is not clear to me that this fully addresses the problem. GCC does not warn
about all possible accesses to uninitialized variables.

> 4. (in theory) Using static analyzer -fanalyzer. It doesn't detect this error
>    at the moment, but I believe can be taught detecting this.

This may be helpful.

> 5. Using dynamic analyzer like valgrind.

This is too expensive for production and also only useful for limited testing.

> It seems that you find existing options insufficient and want another one.

I want the optimizer to assume that uninitialized variables have an unknown but
fixed value. Then one could still optimize almost as well *and* get analyzable
and more benign behavior even when uninitialized variables are accessed.
Optimizers already know how to deal with variables of unknown content, so this
should be fairly easy to implement (maybe I will try).

I would also like something such as -fsanitize=undefined which detects for
uninitialized variables at run-time.

Best,
Martin

Reply via email to