------- Comment #6 from rguenther at suse dot de 2009-04-25 14:17 ------- Subject: Re: gcc-4.4 -Wstrict-aliasing and -Wstrict-aliasing=3 behaves like -Wstrict-aliasing=2 in gcc-4.3
On Sat, 25 Apr 2009, edwintorok at gmail dot com wrote: > ------- Comment #4 from edwintorok at gmail dot com 2009-04-25 14:12 ------- > (In reply to comment #3) > > > > The above is properly optimized. Why do you think that an inline > > function taking void * would fix anything? > > I can't know if memcpy will be inlined, it may just be a function call on > certain systems, with certain compilers. > The inline function should be a more portable way of expressing what I need, > and it shouldn't cause any bugs with -fstrict-aliasing, since gcc already > knows > I gave my pointer to a function taking void*, so anything could happen with > it, > right? No, not if it is inlined (and if not you can as well use memcpy). You can also do (GCC extension) union union_t { unsigned un; char c[4]; }; unsigned bar(char *x) { union union_t u; u.c[0] = x[0]; u.c[1] = x[1]; u.c[2] = x[2]; u.c[3] = x[3]; return u.un; } but that will even generate worse code with GCC than the memcpy (it's even horrible code). Richard. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39895