Re: typechecking
Re: typechecking
- Subject: Re: typechecking
- From: Greg Guerin <email@hidden>
- Date: Mon, 5 May 2008 12:34:46 -0700
Perry Winkel wrote:
>if i do a truly 64-bit compile my addresses also become wider :-)
>and this is not what i want yet.
Why would you be casting 64-bit addresses (pointers) to int?
Your example shows a 64-bit integer being implicitly narrowed to a 32-bit
integer. As I recall, there are already warnings when assigning pointers
to ints without a typecast.
>what i do want is that if i put a number in another number
>that could result in a overflow at runtime, the compiler
>gives me a warning a compile time. the language 'c' has
>a bad history in this (loose typechecking), but things
>have improved over the years and i was wondering how
>to do the trick these days since the code below compiles
>without any warning. this is not ok.
You are talking about implicit narrowing conversions. I'm pretty sure
that's the correct terminology.
Googling keywords:
implicit narrowing conversion
brings up this hit (among others):
<http://gcc.gnu.org/ml/gcc/2004-06/msg01365.html>
As I understand it, the -Wconversion gcc option is the one to use for this.
Read the above URL and its message thread to see some of its shortcomings.
Also read the gcc man page.
If you've tried -Wconversion and it doesn't warn you for your example, then
I think the problem is with GCC.
Note that Java has always rejected all implicit narrowing conversions. It
requires an explicit typecast to compile. I only mention Java because it
seems like its behavior with primitive types is precisely the functionality
you want.
-- GG
_______________________________________________
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