This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Storage for uninitialized objects (PR 24626)


Paul Schlie <schlie@comcast.net> writes:

> Given that it would appear that the only time the compiler may attempt
> to optimize the allocation/use of an un-initialized variable, is when it
> knows for certain it hasn't been initialized; might it be preferable to
> then assign it a deterministic cheap value such as 0 which it may then
> presume during optimization, given all remaining alternatives would seem
> to have less desirable potential consequences?

That would not be desirable in general when optimizing.  The compiler
would not be able to consistently optimize away the initializations to
zero, so a correct program would wind up with useless instructions
which should make it larger and slower.  Usually only a tiny bit
larger and slower, of course, but when optimizing most people prefer
the resulting code to run as fast as possible.  Running as fast as
possible means omitting instructions which are not required.

It would be perfectly reasonable to have a command line option to
initialize automatic variables to zero, of course.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]