The code is as following, when I change the Line15 to (*((struct b_t *)(&dst)) = *((struct b_t *)(&src))) , or I change the Line16 to (*((struct a_t *)(&dst)) = *((struct a_t *)(&src))), it's OK. Quite strange, why two kind of type cast doesn't work. # gcc a.c a.c: In function `main': a.c:15: error: type mismatch in conditional expression ========== a.c ============= struct a_t { int sa_family; }; struct b_t { int sa_family; }; int main() { struct b_t dst, src; (src.sa_family == 1) ? (*((struct a_t *)(&dst)) = *((struct a_t *)(&src))) : (*((struct a_t *)(&dst)) = *((struct a_t *)(&src))); return 0; } -- View this message in context: http://gcc.1065356.n5.nabble.com/Type-cast-doesn-t-work-in-ternary-operator-tp1125877.html Sent from the gcc - Help mailing list archive at Nabble.com.