(e-mail address removed) wrote:
Compile a our source with BM XL C/C++ Enterprise Edition V8.0 for AIX
(Version: 08.00.0000.0000) produces a lot of Informational message
like this:
"aaalib.c", line 671.1: 1506-412 (I) Referenced variable "n", which
was not initialized in its declaration. [...]
P.S. It would be maybe better to SHOW where the compiler
complains, where you think it is wrong with
concrete examples, if not it is not possible to help you
anyway.
here is the code snipped:
void aaalib_trim (char *in) {
int n;
for (n = (strlen(in)) - 1; n>= 0; n--)
if (!isspace(in[n]))
break;
in[n+1] = '\0';
}
Did you merely snip that from your program, or did you actually feed
that smaller chunk of code to the compiler? If the latter, you should
add #include directives for <string.h> and <ctype.h>.
I get that message when I use "xlc -qinfo=uni", which according to the
man page diagnoses "Possible problems with initialization". I also
get it with "-qinfo", which enables all such messages (and gives me
over 600 lines of messages for the standard headers).
I'm a little surprised that the message is produced, since n is never
actually used before a value is assigned to it.
The "(I)" denotes an informational message, which is even less severe
than a warning.
Either the "-qinfo=uni" option is slightly buggy, or it's intended to
encourage a programming style in which *all* variables are initialized
when they're defined. Such a style guarantees that all variables will
have defined values when they're accessed (though it doesn't guarantee
that they'll have *meaningful* values).
Determining that n is never actually accessed before a value has been
assigned to it requires dataflow analysis, which is more work for the
compiler.
As far as the standard is concerned, this is all perfectly legitimate.
A compiler is required to produce diagnostics only for syntax errors,
constraint violations, and the #error directive, none of which occur
in your code sample -- but it's allowed to produce any additional
diagnostics it likes.
See the man page for information on how to disable particular messages
(though I suspect that disabling this particular message might disable
messages about actual uses of uninitialized variables). Failing that,
comp.unix.aix is probably a better place to ask. There *might* be a
way to tell the compiler to warn more intelligently about possible use
of uninitialized variables.
--
Keith Thompson (The_Other_Keith) (e-mail address removed) <
http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <
http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"