-qinfo

Category

Error checking and debugging

Pragma equivalent

#pragma options [no]info, #pragma info

Purpose

Produces or suppresses groups of informational messages.

The messages are written to standard output and, optionally, to the listing file if one is generated. The compiler does not issue messages for the following files:

Syntax

Read syntax diagramSkip visual syntax diagram
Option syntax

>>- -q--+-noinfo-------------------------+---------------------><
        '-info--+----------------------+-'   
                |    .-:-------------. |     
                |    V               | |     
                '-=----+-all-------+-+-'     
                       +-noall-----+         
                       +-als-------+         
                       +-noals-----+         
                       +-group-----+         
                       +-nogroup---+         
                       +-mt--------+         
                       +-nomt------+         
                       +-private---+         
                       +-reduction-+         
                       +-stp-------+         
                       '-nostp-----'         

Read syntax diagramSkip visual syntax diagram
Pragma syntax

                       .-,-------------.      
                       V               |      
>>-#--pragma--info--(----+-all-------+-+--)--------------------><
                         +-none------+        
                         +-als-------+        
                         +-noals-----+        
                         +-group-----+        
                         +-nogroup---+        
                         +-mt--------+        
                         +-nomt------+        
                         +-private---+        
                         +-reduction-+        
                         '-restore---'        

Defaults

-qnoinfo

Parameters

all
Enables diagnostic messages for all groups except als, mt, and ppt.
noall (option only)
Disables all diagnostic messages for all groups.
none (pragma only)
Disables all diagnostic messages for all groups.
als
Enables reporting possible violations of the ANSI aliasing rule in effect.
noals
Disables reporting possible aliasing-rule violations.
group | nogroup
Enables or disables specific groups of messages, where group can be one or more of:
group
Type of informational messages returned or suppressed.
c99 | noc99
C code that may behave differently between C89 and C99 language levels.
cmp | nocmp
Possible redundancies in unsigned comparisons.
cnd | nocnd
Possible redundancies or problems in conditional expressions.
cns | nocns
Operations involving constants.
cnv | nocnv
Conversions.
dcl | nodcl
Consistency of declarations.
eff | noeff
Statements and pragmas with no effect.
enu | noenu
Consistency of enum variables.
ext | noext
Unused external definitions.
gen | nogen
General diagnostic messages.
gnr | nognr
Generation of temporary variables.
got | nogot
Use of goto statements.
ini | noini
Reports array initializers that partially initialize their arrays. If an array is partially initialized, elements that are not initialized receive the value 0 of the appropriate type.
lan | nolan
Language level effects.
obs | noobs
Obsolete features.
ord | noord
Unspecified order of evaluation.
par | nopar
Unused parameters.
por | nopor
Nonportable language constructs.
ppc | noppc
Possible problems with using the preprocessor.
ppt | noppt
Trace of preprocessor actions.
pro | nopro
Missing function prototypes.
rea | norea
Code that cannot be reached.
ret | noret
Consistency of return statements.
trd | notrd
Possible truncation or loss of data or precision.
tru | notru
Variable names truncated by the compiler.
trx | notrx
Hexadecimal-floating point constants rounding.
uni | nouni
Uninitialized variables. The -qinfo=uni option enforces the coding style that a variable must be initialized in its declaration.
unset | nouset (option only)
Detects automatic variables that are used before they are set, and flags them with informational messages at compile time.

-qinfo=unset uses program information, such as control flow information, available during optimization. As a result, detection accuracy improves with the optimization level. For example, some uses of unset variables that are not flagged at -O0 are flagged at -O2. Aggressive optimization levels, such as -O4 and -O5, can cause the line numbers in the informational messages to become inaccurate. In very rare cases, these optimization levels reorder the program sufficiently to cause false positive messages from static analysis. You can get the best results with the -O2 optimization level.

The -qinitauto option initializes automatic variables. As a result, the -qinitauto option hides variables that are used before they are set from the -qinfo=unset option.

upg | noupg
Generates messages describing new behaviors of the current compiler release as compared to the previous release.
use | nouse
Unused auto and static variables.
zea | nozea
Zero-extent arrays.
mt | nomt

Reports potential synchronization issues in parallel code. This suboption detects the Global Thread Flag pattern where one thread uses a shared volatile flag variable to notify other threads that it has completed a computation and stored its result to memory. Other threads check the flag variable in a loop that does not change the flag variable. When the value of the flag variable changes, the waiting threads access the computation result from memory. The PowerPC® storage model requires synchronization before the flag variable is set in the first thread, and after the flag variable is checked in the waiting threads. Synchronization can be done by a synchronization built-in function.

The type of synchronization directives you need to use depends on your code. Usually, it is enough to use the __lwsync function, as it preserves the storage access order to system memory. However, if the loops in the waiting threads are written in such a way that might cause instruction prefetching to start executing code that accesses the computation result before the flag variable is updated, a call to a function like __isync is needed to preserve order. Such patterns are typically as follows:
gotosleep: sleep(value);
   if (!flag) goto gotosleep;   
   // A call to the __isync function is needed here.   
   x = shared_computation_result;

Some patterns that do not require synchronization are similar to the patterns described above. The messages generated by this suboption are only suggestions about potential synchronization issues.

To use the -qinfo=mt suboption, you must enable the -qthreaded option and specify at least one of the following options:
  • -O3
  • -O4
  • -O5
  • -qipa
  • -qhot
  • -qsmp

The default option is -qinfo=nomt.

private
This suboption is deprecated. -qreport replaces it. For details, see -qreport and the Deprecated options section in the XL C Compiler Reference.
reduction
This suboption is deprecated. -qreport replaces it. For details, see -qreport and the Deprecated options section in the XL C Compiler Reference.
stp | nostp
Issues warnings for procedures that are not protected against stack corruption. -qinfo=stp has no effects unless the -qstackprotect option is also enabled. Like other -qinfo options, -qinfo=stp is enabled or disabled through -qinfo=all / noall. -qinfo=nostp is the default option.
restore (pragma only)
Discards the current pragma setting and reverts to the setting specified by the previous pragma directive. If no previous pragma was specified, reverts to the command-line or default option setting.

Usage

Specifying -qinfo with no suboptions is equivalent to -qinfo=all.

Specifying -qnoinfo is equivalent to -qinfo=noall.

Consider the following when enabling the reporting of aliasing-rule violations:
  • -qalias=ansi must be set before reporting of aliasing-rule violations (-qinfo=als) can occur.
  • Any level of optimization or inlining implies -qinfo=noals and a warning will be issued when -qinfo=als is explicitly specified.
  • Diagnostics are heuristic and may emit false positives. Points-to analysis cannot be evaluated deterministically in static compilation. The points-to analysis used for diagnostics is evaluated in a context-and-flow, insensitive manner. The sequence of traceback messages in diagnostics is such that if executed in the order specified, the indirect expression will point to the offending object. If that execution sequence cannot occur in the application, the diagnostic is a false positive. (See the Examples section for the types of diagnostics that can occur.)

Predefined macros

None.

Examples

To compile myprogram.c to produce informational messages about all items except conversions and unreached statements, enter the following command:
xlc myprogram.c -qinfo=all -qinfo=nocnv:norea
The following example shows code constructs that the compiler detects when the code is compiled with -qinfo=cnd:eff:got:obs:par:pro:rea:ret:uni in effect:
#define COND 0  

void faa() // Obsolete prototype (-qinfo=obs) 
{   
   printf("In faa\n"); // Unprototyped function call (-qinfo=pro) 
}  

int foo(int i, int k)  
{
   int j; // Uninitialized variable (-qinfo=uni)    

   switch(i) {   
   case 0:     
   i++;     
   if (COND) // Condition is always false (-qinfo=cnd)       
      i--;   // Unreachable statement (-qinfo=rea)     
   break;    

   case 1:     
      break;     
      i++;   // Unreachable statement (-qinfo=rea)   
   default:     
      k = (i) ? (j) ? j : i : 0;   
}   

   goto L;   // Use of goto statement (-qinfo=got)   
   return 3; // Unreachable statement (-qinfo=rea) 
L:   
   faa(); // faa() does not have a prototype (-qinfo=pro)   
 
// End of the function may be reached without returning a value   
// because of there may be a jump to label L (-qinfo=ret) 

} //Parameter k is never referenced (-qinfo=ref)   

int main(void) {   
({ int i = 0; i = i + 1; i; }); // Statement does not have side effects (-qinfo=eff)   

 return foo(1,2); 
} 

In the following example, the #pragma info(eff, nouni) directive preceding MyFunction1 instructs the compiler to generate messages identifying statements or pragmas with no effect, and to suppress messages identifying uninitialized variables. The #pragma info(restore) directive preceding MyFunction2 instructs the compiler to restore the message options that were in effect before the #pragma info(eff, nouni) directive was specified.

#pragma info(eff, nouni) 
int MyFunction1()
{
  .
  .
  .

}

#pragma info(restore)
int MyFunction2()
{
  .
  .
  .

}
The following example shows a valid diagnostic for an aliasing violation:
t1.c:
int main() {
  short s = 42;
  int *pi = (int*) &s;
  *pi = 63;
  return 0;
}  
xlC -qinfo=als t1.c
"t1.c", line 4.3: 1540-0590 (I) Dereference may not conform to the current 
                                aliasing rules.
"t1.c", line 4.3: 1540-0591 (I) The dereferenced expression has type "int". 
                                "pi" may point to "s" which has incompatible 
                                type "short".
"t1.c", line 4.3: 1540-0592 (I) Check assignment at line 3 column 11 of t1.c.
In the following example, the analysis is context insensitive in that the two calls to floatToInt are not distinguished. There is no aliasing violation in this example, but a diagnostic is still issued.
t2.c:
int* floatToInt(float *pf) { return (int*)pf; }

int main() {
  int i;
  float f;
   int* pi = floatToInt((float*)*&i));
   floatToInt(&f;)
   return *pi;
}  

xlC -qinfo=als t2.c
"t2.c", line 8.10: 1540-0590 (I) Dereference may not conform to the current 
                                 aliasing rules.
"t2.c", line 8.10: 1540-0591 (I) The dereferenced expression has type "int". 
                                 "pi" may point to "f" which has incompatible 
                                 type "float".
"t2.c", line 8.10: 1540-0592 (I) Check assignment at line 7 column 14 of t2.c.
"t2.c", line 8.10: 1540-0592 (I) Check assignment at line 1 column 37 of t2.c.
"t2.c", line 8.10: 1540-0592 (I) Check assignment at line 6 column 11 of t2.c.
t3.c:
int main() {
  float f;
  int i = 42;
  int *p = (int*) &f;
  p = &i;
  return *p;
}

xlC -qinfo=als t3.c
"t3.c", line 6.10: 1540-0590 (I) Dereference may not conform to the current
        aliasing rules.
"t3.c", line 6.10: 1540-0591 (I) The dereferenced expression has type "int". 
        "p" may point to "f", which has incompatible type "float".
"t3.c", line 6.10: 1540-0592 (I) Check assignment at line 4 column 10 of t3.c.
To compile sync.c to produce informational messages about potential synchronization issues in parallel code, enter the following command:
 xlc_r -O3 -qinfo=mt sync.c
Suppose that sync.c contains the following code:
#include <unistd.h>
#include <stdio.h>
#include <pthread.h>

volatile int done;         /* shared flag */
volatile int result;       /* shared result */

void *setter(void *id) 
{
  sleep(5);
  result = 7;
  /* Need __lwsync(); */
  done = 1;                /* line 13 */
}

void *waiter(void *id) 
{
  while (!done)            /* line 18 */
  {
    sleep(1);
  }
  /* need __lwsync(); */
  printf("%d\n", result);
}

int main() 
{
  pthread_t threads[2];
  pthread_attr_t attr;
  int result;
  
  result = pthread_create(&threads[0], NULL, waiter, NULL);
  if (result != 0) exit(2);
  result = pthread_create(&threads[1], NULL, setter, NULL);  
  if (result != 0) exit(3);  
  
  pthread_join(threads[0], NULL); 
  pthread_join(threads[1], NULL);
  
  return 0;
}
The compiler issues the following informational messages:
1586-669 (I) "sync.c", line 18: If this loop is used as a synchronization
point, additional synchronization via a directive or built-in function might
be needed.

1586-670 (I) "sync.c", line 13: If this statement is used as a synchronization
point, additional synchronization via a directive or built-in function might
be needed.
The following function ini.c partially initialized array a[3]. To compile ini.c to produce an informational message about this issue, enter the following command:
xlc -qinfo=ini ini.c -c
Suppose that ini.c contains the following code:
int a[3] = {1};
The compiler issues the following informational message:
"ini.c", line 1.10: 1506-446 (I) Array element(s) [1] ... 
[2] will be initialized with a default value of 0.
The following function factorial.c does not initialize result when n<1. With -qinfo=unset at -qnoopt, this issue is not detected. To compile factorial.c to produce informational messages about the uninitialized variable result, enter the following command:
xlc -qinfo=unset -O factorial.c
factorial.c contains the following code:
int factorial(int n) {
  int result;
 
  if (n > 1) {
    result = n * factorial(n - 1);
  }
 
  return result; /* line 8 */
}
 
int main() {
  int x = factorial(1);
  return x;
} 
The compiler issues the following informational message:
1500-099: (I) "factorial.c", line 8: "result" might be used before it is set.

Related information