I found myself in the following situation:
#include <stdio.h>
typedef struct T1 { int id; } T1;
typedef struct T2 { int id; } T2;
void f(T1 *ptr) { printf("f called\n"); }
int main(void)
{
T2 obj;
T2 *ptr = &obj;
f(ptr); // shouldn't this be a compilation error ?
return 0;
}
of course, this is invalid C++, but in C, the program prints "f called". How is this valid ?
EDIT
(Just in case it's unclear) The program would still compile and run if T2
was "structurally" different, eg
typedef struct T2 { double cc[23]; } T2;