Undefined warnings only with optimization turned on? 
Author Message
 Undefined warnings only with optimization turned on?

Hi,

This morning I managed to shed another layer of ignorance:

   The Cray fortran compiler emits more "used uninitialized"
   sorts of warnings when optimization is enabled (-O2) than
   without (-O0).

Is this more or less true for all compilers?

If so, I need to turn on optimization for our compiler gauntlet,
which currently uses -O0 to minimize compile time.

Thanks in advance,
--
Bil Kleb
http://www.*-*-*.com/
http://www.*-*-*.com/



Tue, 06 Sep 2011 21:58:39 GMT  
 Undefined warnings only with optimization turned on?

Quote:
> Hi,

> This morning I managed to shed another layer of ignorance:

>    The Cray Fortran compiler emits more "used uninitialized"
>    sorts of warnings when optimization is enabled (-O2) than
>    without (-O0).

> Is this more or less true for all compilers?

> If so, I need to turn on optimization for our compiler gauntlet,
> which currently uses -O0 to minimize compile time.

> Thanks in advance,

Compile time detection of "used uninitialized" is based on doing flow
analysis of the user program.

Optimization                                   is based on doing flow
analysis of the user program.

Doing flow analysis slows the compilation process. Folks are not so
charmed with slow compilation but will be more tolerant of slow compilation
at higher optimization levels. So it is plasusible that you will see
more unused diagnostics with higher optimization levels.

Of course if you want to see "used uninitialized" both for easy to detect
at compile time and impossible to detect at compile time then you have
to enable the runtime checking for undefined variables. Such debugging
if usually done with low levels of optimization so you get quick compiles
and ALL such errors found for the data you use. Execution will be slower
but this is still the debugging phase.

It is trivial to construct examples of impossible to detect at compile time
cases. The completeness of the runtime checks depends on the thouroughness of
your test cases. Not all compiler vendors offer undefined variable checking
so good serious debugging will require several compilers. Multiple compilers
help with portability, quality code and other good things. Think of it as an
aid for clear thinking which is always a good thing but often in short supply.



Tue, 06 Sep 2011 22:15:33 GMT  
 Undefined warnings only with optimization turned on?

Quote:

> Hi,

> This morning I managed to shed another layer of ignorance:

>    The Cray Fortran compiler emits more "used uninitialized"
>    sorts of warnings when optimization is enabled (-O2) than
>    without (-O0).

> Is this more or less true for all compilers?

Not for all or even many, but it is understandable. To determine that the variable x is uninitialized when first used in the code fragment

  ....
  j=1
  ....
  s=0
  if(mod(j,2).eq.0)x=1
  s=s+x
  ....

requires that the value of j be known to the compiler when it is analyzing the 'if' statement. With -O0, a compiler need not subject large segments of code to analysis, and may analyze as few statements (down to one) as necessary to compile into object code.

I faintly recall mention of this counterintuitive feature in this newsgroup a few weeks ago.

Quote:
> If so, I need to turn on optimization for our compiler gauntlet,
> which currently uses -O0 to minimize compile time.

> Thanks in advance,
> --
> Bil Kleb
> http://fun3d.larc.nasa.gov
> http://twitter.com/bil_kleb

-- mecej4


Tue, 06 Sep 2011 22:19:52 GMT  
 Undefined warnings only with optimization turned on?

Quote:

>   The Cray Fortran compiler emits more "used uninitialized"
>   sorts of warnings when optimization is enabled (-O2) than
>   without (-O0).

> Is this more or less true for all compilers?

Not all, but gnu compilers require -O, otherwise -Wuninitialized has no
effect.  The warning depends on compiler analysis of execution paths.


Tue, 06 Sep 2011 22:30:06 GMT  
 Undefined warnings only with optimization turned on?

Quote:


>>   The Cray Fortran compiler emits more "used uninitialized"
>>   sorts of warnings when optimization is enabled (-O2) than
>>   without (-O0).

>> Is this more or less true for all compilers?

I believe that most compilers will find more uninitialized variables
with than without optimization turned on. It depends on the compiler
implementation, however, whether the difference is be big or small (cf.
below).

Quote:
> Not all, but gnu compilers require -O, otherwise -Wuninitialized has no
> effect.  The warning depends on compiler analysis of execution paths.

Well, the former will change with GCC 4.4.0:

"Uninitialized warnings do not require enabling optimization anymore,
that is, -Wuninitialized can be used together with -O0. Nonetheless, the
warnings given by -Wuninitialized will probably be more accurate if
optimization is enabled."

http://gcc.gnu.org/gcc-4.4/changes.html

Tobias



Wed, 07 Sep 2011 00:12:40 GMT  
 Undefined warnings only with optimization turned on?

Quote:

> Hi,

> This morning I managed to shed another layer of ignorance:

>    The Cray Fortran compiler emits more "used uninitialized"
>    sorts of warnings when optimization is enabled (-O2) than
>    without (-O0).

> Is this more or less true for all compilers?

For optimisation, compilers do a more thorough analysis of the
source in order to produce that optimisation.
That could include checks for initialisation as a "bonus".

It is not, however, true that all compilers produce additional
messages about lack of initialization.

Quote:
> If so, I need to turn on optimization for our compiler gauntlet,

A gauntlet is a glove.  Do you mean "gantlet"?
Quote:
> which currently uses -O0 to minimize compile time.

> Thanks in advance,
> --
> Bil Kleb



Wed, 07 Sep 2011 08:26:58 GMT  
 Undefined warnings only with optimization turned on?

Quote:

> > Hi,

> > This morning I managed to shed another layer of ignorance:

> >    The Cray Fortran compiler emits more "used uninitialized"
> >    sorts of warnings when optimization is enabled (-O2) than
> >    without (-O0).

> > Is this more or less true for all compilers?

> > If so, I need to turn on optimization for our compiler gauntlet,
> > which currently uses -O0 to minimize compile time.

> > Thanks in advance,

> Compile time detection of "used uninitialized" is based on doing flow
> analysis of the user program.

> Optimization                                   is based on doing flow
> analysis of the user program.

> Doing flow analysis slows the compilation process. Folks are not so
> charmed with slow compilation but will be more tolerant of slow compilation
> at higher optimization levels. So it is plasusible that you will see
> more unused diagnostics with higher optimization levels.

> Of course if you want to see "used uninitialized" both for easy to detect
> at compile time and impossible to detect at compile time then you have
> to enable the runtime checking for undefined variables. Such debugging
> if usually done with low levels of optimization so you get quick compiles
> and ALL such errors found for the data you use. Execution will be slower
> but this is still the debugging phase.

In general, that is so, but it isn't necessarily so.
Some compilers use(d) a certain value to indicate uninitialised (e.g.,
-2147483628 in a 32-bit integer word),
and a test for such a value makes negligible impact on run time,
and can be available at all levels of optimisation.

- Show quoted text -

Quote:
> It is trivial to construct examples of impossible to detect at compile time
> cases. The completeness of the runtime checks depends on the thouroughness of
> your test cases. Not all compiler vendors offer undefined variable checking
> so good serious debugging will require several compilers. Multiple compilers
> help with portability, quality code and other good things. Think of it as an
> aid for clear thinking which is always a good thing but often in short supply.



Wed, 07 Sep 2011 08:26:59 GMT  
 Undefined warnings only with optimization turned on?

Quote:

> It is not, however, true that all compilers produce additional
> messages about lack of initialization.

I may soon find out -- although, we've taken care of all the ones
from Cray -O2.

Quote:
> A gauntlet is a glove.  Do you mean "gantlet"?

My Apple dictionary (New Oxford American) indicates "gantlet"
is a variant spelling of "gauntlet"?

I use "gauntlet" in the sense of "running the gauntlet", cf.,

   http://www.phrases.org.uk/meanings/run-the-gauntlet.html

Regards,
--
Bil Kleb
http://fun3d.larc.nasa.gov
http://twitter.com/bil_kleb



Wed, 07 Sep 2011 09:19:32 GMT  
 Undefined warnings only with optimization turned on?

Quote:


> > It is not, however, true that all compilers produce additional
> > messages about lack of initialization.

> I may soon find out -- although, we've taken care of all the ones
> from Cray -O2.

> > A gauntlet is a glove.  Do you mean "gantlet"?

> My Apple dictionary (New Oxford American) indicates "gantlet"
> is a variant spelling of "gauntlet"?

> I use "gauntlet" in the sense of "running the gauntlet", cf.,

That is wrong, according to Collins.

If you wish to use medieval terms, at least get them right!
You "throw down the gauntlet", but you "run the gantlet".
You can't "run a glove", (gauntlet means glove, as I said)



Thu, 08 Sep 2011 08:04:14 GMT  
 Undefined warnings only with optimization turned on?

Quote:

> If you wish to use medieval terms, at least get them right!
> You "throw down the gauntlet", but you "run the gantlet".
> You can't "run a glove", (gauntlet means glove, as I said)

Easy as cake!

or was it Piece of pie.

-- glen



Thu, 08 Sep 2011 08:23:23 GMT  
 Undefined warnings only with optimization turned on?
Quote:



>>> It is not, however, true that all compilers produce additional
>>> messages about lack of initialization.
>> I may soon find out -- although, we've taken care of all the ones
>> from Cray -O2.

>>> A gauntlet is a glove.  Do you mean "gantlet"?
>> My Apple dictionary (New Oxford American) indicates "gantlet"
>> is a variant spelling of "gauntlet"?

>> I use "gauntlet" in the sense of "running the gauntlet", cf.,

> That is wrong, according to Collins.

...
That is one; another is

"gauntlet n.  1. a former punishment, chiefly military, in which the
offender was made to run between tow rows of men who struck at him with
switches or weapons as he passed.  2.  the tow rows of men administering
this punishment.  3.  an attack from tow or all sides.  4. trying
conditions; an ordeal.  5. gantlet (def 1) [which is yours of above] 6.
run the gauntlet, to suffer severe criticism or tribulation.  ...
[1670-80; alter. of GANTLOPE]"

--Random House Dictionary of the English Language

--



Thu, 08 Sep 2011 08:33:43 GMT  
 Undefined warnings only with optimization turned on?

Quote:




> >>> It is not, however, true that all compilers produce additional
> >>> messages about lack of initialization.
> >> I may soon find out -- although, we've taken care of all the ones
> >> from Cray -O2.

> >>> A gauntlet is a glove.  Do you mean "gantlet"?
> >> My Apple dictionary (New Oxford American) indicates "gantlet"
> >> is a variant spelling of "gauntlet"?

> >> I use "gauntlet" in the sense of "running the gauntlet", cf.,

> > That is wrong, according to Collins.
> ...
> That is one; another is

> "gauntlet n.  1. a former punishment, chiefly military, in which the
> offender was made to run between tow rows of men who struck at him with
> switches or weapons as he passed.  2.  the tow rows of men administering
> this punishment.  3.  an attack from tow or all sides.  4. trying
> conditions; an ordeal.  5. gantlet (def 1) [which is yours of above] 6.
> run the gauntlet, to suffer severe criticism or tribulation.  ...
> [1670-80; alter. of GANTLOPE]"

> --Random House Dictionary of the English Language

Collins:
"gantlet n. [definitions like 1 to 4 above] --
"to run the gantlet (erroneously, gauntlet), to undergo this ordeal;
"to face any unpleasant ordeal."


Fri, 09 Sep 2011 19:00:22 GMT  
 Undefined warnings only with optimization turned on?

Quote:

> Collins:
> "gantlet n. [definitions like 1 to 4 above] --
> "to run the gantlet (erroneously, gauntlet), to undergo this ordeal;
> "to face any unpleasant ordeal."

My dictionaries concur in Gauntlet or Ganlet as
a) an armoured or long-sleeved glove, used to challenge at combat
(conveniently at hand, and you don't throw down your weapons). From
middle english "gantelet" or gant glove
This is why duelers still use the handy hand-glove for the purpose.

b) a challenging and dangerous narrow course between two points of
security;  from  French "gantlope" or gated course.



Sat, 10 Sep 2011 20:00:03 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. Turning compiler optimizations off causes segmentation fault

2. LWW - turning off warnings

3. compiler warnings about undefined functions

4. WARNING - Windows 98 Second Edition Updates - WARNING

5. Warning in C5 : Warning: Label duplicated, second used ABCDLLMODE

6. Warning - another warning question

7. How suppress Xilinx XCT complier warnings: WARNING:HDLCompilers?

8. JESUS the SCARS!!!!!!!!WARNING WARNING

9. Turn off certain warnings when loading a file in Quintus?

10. OTI Turns Blue

11. Smalltalk turns 20

 

 
Powered by phpBB® Forum Software