This is the mail archive of the gcc-help@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: implicit cast from unsigned long to unsigned int gives no warning with -Wall (64 bits arch)


Vincent Torri wrote:
I want to know why you assume j = ... should give a warning but not i = 0. (hint: what is the type of 0?).

In C, casts are implicit. That's how you can do things like

int ch = 'a';

you can't loose data here, while a cast from a 64bits int to a 32 bits can loose data.


I was not precise enough : i was expecting a warning on the line where htonl is called

But that's not a standard violation. It's well defined what that will do.

I think 4.3 has a warning for that [or something like that]. Failing that you need a typesafe language, or simpler yet, don't mix data types.

I never understand the fascination with using every valid C data type just for the sake of diversity. Use typedef's or whatever and be done with.

Tom


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