I see a lot of APIs (e.g. Cyrus SASL) that have accessor functions
returning values through a void ** argument. As far as I can tell, this
doesn't actually cause any problems, but gcc 4.1 with -Wstrict-aliasing
will complain. For example, take these two separate source files:
alias1.c
####
#include <stdio.h>
extern void getit( void **arg );
main() {
int *foo;
getit( (void **)&foo);
printf("foo: %x\n", *foo);
}
####
alias2.c
####
static short x[] = {16,16};
void getit( void **arg ) {
*arg = x;
}
####
gcc -O3 -fstrict-aliasing -Wstrict-aliasing *.c -o alias
The program prints the expected result with both strict-aliasing and
no-strict-aliasing on my x86_64 box. As such, when/why would I need to
worry about this warning?
--
-- Howard Chu
Chief Architect, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc
OpenLDAP Core Team http://www.openldap.org/project/