aMule Forum

English => en_Bugs => Topic started by: skolnick on November 14, 2011, 01:56:42 AM

Title: lots of warnings while compiling
Post by: skolnick on November 14, 2011, 01:56:42 AM
Hi!

While compiling aMule I see lots of warnings like these:

Code: [Select]
ArchSpecific.h: In member function 'bool CServerSocket::ProcessPacket(const uint8_t*, uint32, int8)':
ArchSpecific.h:129: warning: dereferencing pointer 'p.949' does break strict-aliasing rules
ArchSpecific.h:129: note: initialized from here
ArchSpecific.h:201: warning: dereferencing pointer 'p.954' does break strict-aliasing rules
ArchSpecific.h:201: note: initialized from here
ArchSpecific.h:201: warning: dereferencing pointer 'p.954' does break strict-aliasing rules
ArchSpecific.h:201: note: initialized from here
ArchSpecific.h:141: warning: dereferencing pointer 'p.950' does break strict-aliasing rules
ArchSpecific.h:141: note: initialized from here
ArchSpecific.h:141: warning: dereferencing pointer 'p.950' does break strict-aliasing rules
ArchSpecific.h:141: note: initialized from here

IIRC, Kry said some time ago that these were not harmful. However, I'm a bit of a perfectionist and I dislike warnings on the software I compile. I researched the issue and got this link: http://blog.worldofcoding.com/2010/02/solving-gcc-44-strict-aliasing-problems.html which I didn't understood fully, but it seems to have the way to correct this in a proper way. Could this issue please be reviewed and solved in a not-so-distant-future release? it seems this issue is produced only by a few lines on the file ArchSpecific.h (as per the warnings thrown).

Thanks, and best regards
Title: Re: lots of warnings while compiling
Post by: Kry on November 14, 2011, 06:36:19 AM
In that file, we want to extract a uint32 value (for example) from a void*. We do some voodoo casting on non-arm/sparc platforms, and gcc complains (which is correct... for some platforms). While I disagree about the complains (for some platforms), the only completely correct, std-compliant, non-warning solution is to use the arm/sparc variant for all platforms.

However, I'm betting you're using gcc 4.4 or something older like that. Am I right? Not only will g++-4.4 complain about stuff like this, it can break the compiled binary. But, using g++-4.6 won't complain or break the code.

Funny how that works.

So, first question, what gcc version are you using?



Title: Re: lots of warnings while compiling
Post by: GonoszTopi on November 14, 2011, 11:48:55 AM
Actually I already tried some magic to replace that voodoo with something even blacker. It turned out that gcc's __builtin_memcpy() produced the best code (which memcpy() equals to in optimized builds). However, that's not a solution for other compilers, nor for gcc without optimizations enabled.
Title: Re: lots of warnings while compiling
Post by: skolnick on November 17, 2011, 03:43:55 AM
So, first question, what gcc version are you using?

Thanks for the explanation, Kry. You are indeed right, I'm using gcc 4.4.4 because it's the one included in RHEL/CentOS 6. I think I'll just ignore the warnings by not looking at the screen while it compiles :P

Regards.
Title: Re: lots of warnings while compiling
Post by: GonoszTopi on December 23, 2011, 04:20:08 PM
Should be fixed now by rev. 10703
Title: Re: lots of warnings while compiling
Post by: skolnick on January 02, 2012, 09:08:09 PM
Thanks a lot GonoszTopi :)