This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch for various warnings in gcc
- From: Dale Johannesen <dalej at apple dot com>
- To: John David Anglin <dave at hiauly1 dot hia dot nrc dot ca>
- Cc: Dale Johannesen <dalej at apple dot com>, ghazi at caip dot rutgers dot edu (Kaveh R. Ghazi), dave dot anglin at nrc dot ca, matz at suse dot de, gcc-patches at gcc dot gnu dot org
- Date: Thu, 8 Aug 2002 10:05:11 -0700
- Subject: Re: Patch for various warnings in gcc
On Thursday, August 8, 2002, at 08:57 AM, John David Anglin wrote:
int main()
{
int a = a;
return a;
}
I tried it under HP cc (hpux10.20) and VAX Ultrix pcc, with and without
"-O".
All compile without error and execute returning a status of 0, except
for HP cc at -O:
This code is nondeterministic and I would expect most users to be happy to
be warned about it. (The fact that some other compilers don't warn may
be a bug IMO, they may see "int a=" and set the Initialized bit, and
there goes the warning.) One of our users did this:
type1 a;
{
type2 a = (type2)a;
under the impression that the last a referred to the outer-block a. (Not
everybody is a language lawyer.) A warning would have helped him. It
seems to me this kind of mistake is more common than any legitimate use
for the construct; indeed, I can't think of a use that does something
useful.