christos%astron.com@localhost (Christos Zoulas) writes: >>It doesn't make any sense to me -- there shouldn't be any alignment >>work-arounds necessary here (should there?), and I see no other possible >>reason for it. >> >> >>--- login_cap.c 10 Feb 2007 12:57:39 -0500 1.25 >>+++ login_cap.c 01 Jul 2009 15:14:06 -0400 >>@@ -517,8 +517,8 @@ >> if (!res) >> return -1; >> >>- ptr = (char *)(void *)&res[count]; >>- (void)strcpy(ptr, str); >>+ ptr = (char *) &res[count]; >>+ (void) strcpy(ptr, str); >> >> /* split string */ >> for (i = 0; (res[i] = stresep(&ptr, stop, '\\')) != NULL; ) >> > > Typically used to shut up gcc type punning warnings. Not that it is the TRTTD > in all cases. Does anyone know if this makes gcc produce "the wanted" code > (has the effect of -fno-strict-aliasing) or it just shuts up the warning? I think the C99 spec says that a void* can alias other types, so you don't get the warning because the unwarranted assumption isn't made, and this should be safe. If res is a char[] this shouldn't be needed, but the + half of the diff hints that it isn't.
Attachment:
pgpBWvS7yNAps.pgp
Description: PGP signature