• 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
Re: Finding typecasts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding typecasts


  • Subject: Re: Finding typecasts
  • From: "Sean McBride" <email@hidden>
  • Date: Tue, 18 Aug 2009 17:43:04 -0400
  • Organization: Rogue Research Inc.

On 8/18/09 5:23 PM, Dan White said:

>Depends how he did it.
>
>Did he cast ?
>
>int foo = (int)(pointer) ;
>
>or did he just "do it" implicitly ?
>
>int foo = pointer + 1 ?
>
>Strikes me that it would be very tough to automate finding either of
>those.

The latter is easy:

------
int main (int argc, char * const argv[])
{
	void* foo = 0;
	int bar = foo + 1;

	return 0;
}
------

gcc-4.2 -Wall ~/Desktop/test.c

test.c:4: warning: initialization makes integer from pointer without a cast

The former is harder, because the cast is basically telling the compiler
to shut up.  You could always search for "(int)". :9

If it were C++, you might search for static_cast or reinterpret_cast.

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


 _______________________________________________
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

References: 
 >Finding typecasts (From: Mark Wagner <email@hidden>)
 >Re: Finding typecasts (From: Dan White <email@hidden>)

  • Prev by Date: Re: Finding typecasts
  • Next by Date: Re: Finding typecasts
  • Previous by thread: Re: Finding typecasts
  • Next by thread: Re: Finding typecasts
  • Index(es):
    • Date
    • Thread