• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Another useless warning - 'Hidden Local Variables'
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Another useless warning - 'Hidden Local Variables'


  • Subject: Another useless warning - 'Hidden Local Variables'
  • From: Matt Gough <email@hidden>
  • Date: Wed, 23 Jul 2008 14:23:14 +0200

I was hoping to use 'Hidden local variables' (GCC_WARN_SHADOW) to catch this sort of common error:

{
	bool eraseEntireInternet = true;
	if (!AskUserIfTheyReallyWantToEraseEntireInternet())
	{
		bool eraseEntireInternet = false;
		// Oops - I meant to assign to the top level value here
		// but I stupidly copied the entire declaration
		// and just changed true to false.
		....
	}

if (eraseEntireInternet)
EraseEntireInternet(); // Oh well - What was it ever good for anyway :)
}



but it is really useless as it also warns about this sort of thing:

class Foo
{
	size_t size() const;
	void setSize(size_t size);

	size_t mSize;
}

void Foo::setSize(size_t size) << Warning - declaration of 'size' shadows a member of 'this'
{
mSize = size;
}


To me this is just dumb that Foo::size() is considered a contender for being shadowed. I know that it could be interpreted as me wanting to assign the address of Foo::size() to mSize.

Is there anyway to make this warning only consider real variables (either local, global or class) and to not moan about method names too? Our project has over 10,000 such warnings, so I am not going to go through it and rename all my method parameters to avoid such clashes. As such, its possible that a few 'real' problems will be missed.


Matt Gough _______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Another useless warning - 'Hidden Local Variables'
      • From: "Eric Miller" <email@hidden>
  • Prev by Date: Re: Gcc warning instead of error
  • Next by Date: Re: Gcc warning instead of error
  • Previous by thread: Re: Is iPhone discussion allowed at this point?
  • Next by thread: Re: Another useless warning - 'Hidden Local Variables'
  • Index(es):
    • Date
    • Thread