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]
Other format: [Raw text]

Re: Type-punning


On 6/26/07, Herman Geza <hg211@hszk.bme.hu> wrote:

Let me elaborate. If the compiler can detect invalid type-punning,
Not really.

void foo(float *a) {
        int *b = (int*)a; // type-punning warning
}

This is actually valid if we don't access both a and b and also the original type is int.

Is this reasonable?

Not really, see above. Aliasing is a hard problem to solve in generic. So there are stuff like type based aliasing to help out the solver. And in the case of GCC, it helps out more than other compilers.

-- Pinski


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