473,804 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AIX C compiler message unexplainable

Hi All

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.

n is a variable in procedure an is assigned before used. Compiling the
same sources with other compiles such as AIX version 7.0, gcc on
linux etc do not display this information.

Appreciate your help in this regard,

Thanks,
Andreas

Oct 17 '07
18 2964
jacob navia wrote:
Roberto Waltman wrote:
>>
void aaalib_trim (char *in) {
int n = strlen(in) - 1;
for ( ; n>= 0; n--)
if (!isspace(in[n]))
break;
in[n+1] = '\0';
}

strlen(in) is always greater than 1, right? ;)

strlen can be zero. Then, strlen(in)-1 is -1.
Actually, `strlen("")-1' is `(size_t)-1', an unsigned
value that is at least 65535 and possibly larger. On most
systems, converting this large value to an `int' will yield
the value -1, but that's just dumb luck and not a feature
of the C language.

--
Eric Sosman
es*****@ieee-dot-org.invalid
Oct 17 '07 #11
On 2007-10-17, an************@ gmx.net <an************ @gmx.netwrote:
On Oct 17, 1:13 pm, jacob navia <ja...@nospam.o rgwrote:
>andreas.lue... @gmx.net wrote:
Hi All
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.
[snip]
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';
}
Does the compiler write the message when you compile that snippet?
What compiler options are you using?
Oct 17 '07 #12
an************@ gmx.net writes:
On Oct 17, 1:13 pm, jacob navia <ja...@nospam.o rgwrote:
>andreas.lue... @gmx.net 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.hand <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_Keit h) ks***@mib.org <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"
Oct 17 '07 #13
On Oct 17, 11:37 pm, Keith Thompson <ks...@mib.orgw rote:
andreas.lue...@ gmx.net writes:
On Oct 17, 1:13 pm, jacob navia <ja...@nospam.o rgwrote:
andreas.lue...@ gmx.net 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.hand <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_Keit h) ks...@mib.org <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"

The code is only a small snip, the whole source has all the #include
directives.

The make file we use includes an other one from oracle (env_rdbms.mk)
which has a "-qinfo=uni" in it. I could compile with "-qflag=w:w",
that
seems to override the qinfo, but then I also miss all other "(I)"
messages
as well. An other solution is to change the qinfo from env_rdbms.mk in
my
makefile with: "CCFLAGS += -qnoinfo".

The compiler Information "...was not initialized in its declaration"
is of
course true, but as you mentioned n is never accessed before a value
has
been assigned. But this seem to me an unnecessary information unless I
use
such a uninitialized variable.

Andreas

Oct 18 '07 #14
an************@ gmx.net wrote:
On Oct 17, 11:37 pm, Keith Thompson <ks...@mib.orgw rote:
>andreas.lue... @gmx.net writes:
>>On Oct 17, 1:13 pm, jacob navia <ja...@nospam.o rgwrote:
andreas.lue. ..@gmx.net 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.
The make file we use includes an other one from oracle (env_rdbms.mk)
which has a "-qinfo=uni" in it.
http://tinyurl.com/26j5b6 suggests that everything is behaving as
designed. The make files request this warning, so the compiler provides it.

I suggest you try adding -qinfo=nouni to your options, after the oracle
make file has been included, if you don't want the information.
Oct 18 '07 #15
an************@ gmx.net wrote:
jacob navia <ja...@nospam.o rgwrote:
>andreas.lue... @gmx.net 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
Information al message like this:
>>"aaalib.c", line 671.1: 1506-412 (I) Referenced variable "n",
which was not initialized in its declaration.
.... snip ...
>
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';
}
strlen returns a size_t. An int is not necessarily able to hold a
size_t.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Oct 19 '07 #16
an************@ gmx.net 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.

n is a variable in procedure an is assigned before used. Compiling
the same sources with other compiles such as AIX version 7.0, gcc
on linux etc do not display this information.
After close examination of the detailed source provided, I conclude
that the error is in line 42.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Oct 19 '07 #17
"Eric Sosman" <es*****@ieee-dot-org.invalida écrit dans le message de
news: eZ************* *************** **@comcast.com...
jacob navia wrote:
>Roberto Waltman wrote:
>>>
void aaalib_trim (char *in) {
int n = strlen(in) - 1;
for ( ; n>= 0; n--)
if (!isspace(in[n]))
break;
in[n+1] = '\0';
}

strlen(in) is always greater than 1, right? ;)

strlen can be zero. Then, strlen(in)-1 is -1.

Actually, `strlen("")-1' is `(size_t)-1', an unsigned
value that is at least 65535 and possibly larger. On most
systems, converting this large value to an `int' will yield
the value -1, but that's just dumb luck and not a feature
of the C language.
That is not dumb luck, it is a well-thought side-effect of 2s complement
representation and wrap-around arithmetics.
IMO, it *should* be made a feature of the language so conversions between
signed and unsigned types always have defined behaviour and be reversible.
Converting a signed type to unsigned and back to signed should produce the
same value, and vice-versa, and should not alter its representation. Most
current architectures have this behaviour (I know MMX/SSE instructions
implement saturated arithmetics, but that's a separate issue).

Mandating this behaviour would effectively retire ones-complement and
sign-magnitude representations , together with padding bits and
trap-representations for integers. Not a big loss, a welcome simplification
of the standard, and a more intuitive behaviour for most programmers.

It would also cut the amount of pedantic noob-bashing on this forum.

--
Chqrlie.
Oct 26 '07 #18
Charlie Gordon wrote:
"Eric Sosman" <es*****@ieee-dot-org.invalida écrit:
.... snip ...
>
>Actually, `strlen("")-1' is `(size_t)-1', an unsigned value that
is at least 65535 and possibly larger. On most systems,
converting this large value to an `int' will yield the value -1,
but that's just dumb luck and not a feature of the C language.

That is not dumb luck, it is a well-thought side-effect of 2s
complement representation and wrap-around arithmetics.
No, it is 'dumb luck'. The conversion to int will probably exceed
the value range of an int, and this always causes an implementation
defined action. Good 2's complementation implementaions (which are
rare) will probably cause a system error to occur.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Oct 26 '07 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5111
by: Tim Lambert | last post by:
Is there any bytecode advantage to using the Sun 1.4 compiler vs the 1.3 compiler (on Windows). Does the 1.4 compiler produce better and/or faster bytecode than the 1.3 compiler? In other words, is there any advantage to compiling code that was developed against JDK 1.3 and compiling with the 1.4 compiler? Thanks very much for feedback.
8
1907
by: jon morgan | last post by:
OK, I'm going to be brave. There is a bug in VS.Net 1.1 that causes random compiler errors. I have raised this issue in posts at least three time in the past couple of months without attracting much interest. But it's driving me nuts. Here's what happens. I'm working on a multi project VB app. happily writing nice inoffensive code - go to compile and the compiler tells me there's a problem in a project I'm not working on. But really...
30
2963
by: Neil Zanella | last post by:
Hello, Allow me to share my frustrations with GNU g++. This is the second time something similar happens to me: I can't find anything wrong with my C++ program and yet I get segfaults, and eventually, here is what happens. Anyone ever experience anything similar. This or similar untrackable problems happen to me whenever I write a large class... anyone have had similar experiences??? make
16
2856
by: pj | last post by:
(Was originally, probably wrongly, posted to the vc subgroup.) (This doesn't appear to be a c# problem, but a problem with a bug in the Visual Studio c# compiler, but, any help will be welcome...) Oh, I forgot to list the error messages; I would be delighted if someone could explain how to deduce which line number in which file is the one that the VC compiler cannot handle. Actually I'm using C#, but the only post I could find about...
3
5269
by: Mark Rockman | last post by:
------ Build started: Project: USDAver2, Configuration: Debug .NET ------ Preparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error (0xc0000005 at address 535F072A): likely culprit is 'BIND'. An internal error has occurred in the compiler. To work around this problem, try simplifying or changing the program near the locations listed below. Locations at the top of the list are...
41
18235
by: Miroslaw Makowiecki | last post by:
Where can I download Comeau compiler as a trial version? Thanks in advice.
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9169
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7633
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.