This is the mail archive of the gcc@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]

Re: -Wstrict-aliasing in 2.95/6?


> Criterion for warning about suspicious casts:
> 
>       - Any conversion from pointer-to-A to pointer-to-B where
>         type-based aliasing determines that A and B do not alias.
>         (But conversion to/from `void *' never warns).
> 
>       - Any conversion from pointer-to-A to/from a non pointer type.
> 
> Too easy?

Yes. It would not have caught the original example __constant_memcpy,
because this function expects void*, and converts those to int, for
efficient copying. What example of the Linux kernel would have been
detected by that rule?

Also, you should treat char* very much like void*: ISO C allows to
access any object through a char*.

The danger of such a rule is that people assume their code is safe
when they don't get warnings, when it is not.

Regards,
Martin


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