This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]