* extra c++ warnings
@ 1997-12-30 12:07 George
0 siblings, 0 replies; only message in thread
From: George @ 1997-12-30 12:07 UTC (permalink / raw)
To: egcs
The C++ end of egcs (and gcc 2.7.2.3) gives warnings on && constructs that
the C portion does not.
Example:
greerga@bacon:~/c$ cat warning.cpp
#include <stdio.h>
#include <stdlib.h>
int return_0(void) { return 0; }
int main(void)
{
int j;
if (return_0() == 0 && (j = return_0()) == 0)
printf("%d\n", j);
return 0;
}
greerga@bacon:~/c$ egcs++ -O2 -Wall warning.cpp
warning.cpp: In function `int main()':
warning.cpp:8: warning: `int j' might be used uninitialized in this function
greerga@bacon:~/c$ mv warning.cpp warning.c
greerga@bacon:~/c$ egcs -O2 -Wall warning.c
greerga@bacon:~/c$
It doesn't realize that in order to get to the printf, the assignment must
happen.
However, the following works without error:
greerga@bacon:~/c$ cat warning.cpp
#include <stdio.h>
#include <stdlib.h>
int return_0(void) { return 0; }
int main(void)
{
int j;
if (0 == 0 && (j = return_0()) == 0)
printf("%d\n", j);
return 0;
}
greerga@bacon:~/c$ egcs++ -O2 -Wall warning.cpp
greerga@bacon:~/c$
It seems to only happen when the first part calls a function (a comparison
against a variable, such as 'i == 4' does not provoke the warning either)
-George Greer
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1997-12-30 12:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-12-30 12:07 extra c++ warnings George
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).