RE: Eliminating GCC 3.3 warning
Bill Radcliffe <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.core |
|---|---|
| Message-ID | <306F012D0A00D611BC9D0008C791927408061394@seamail1.continuum.corbis.corp> |
I would not mind seeing an across that board change made if done carefully. It seems like it would increase code stability. -----Original Message----- From: Bob Friesenhahn [mailto:[email protected]] Sent: Thursday, May 15, 2003 5:57 PM To: GraphicsMagick Core Cc: Bill Radcliffe Subject: Eliminating GCC 3.3 warning GCC 3.3 warns like: warning: dereferencing type-punned pointer will break strict-aliasing rules for code like LiberateMemory((void **) &pixels); When -Wall (enable all reasonable warnings) is applied. This is quite annoying, and has to do with casting the address pointer to a lesser type, which is apparently often a source of bugs. I haven't found a cast which makes the warning go away. If I use #define LiberateMemory(memory) \ { \ assert(memory != 0); \ void *mp=*memory; \ if (mp != 0) LiberateMemory(&mp); \ *memory=0; \ } LiberateMemory(&pixels); then there is no warning, but notice I have to remove the cast from the LiberateMemory calls so there would be code changes in order to avoid the warning. Naturally, these calls are made all over the place. The need to cast the argument to LiberateMemory is actually pretty annoying, so it may be that a macro would help. Does anyone have a bright idea as to how to avoid this warning with minimal changes? Bob ====================================== Bob Friesenhahn [email protected] http://www.simplesystems.org/users/bfriesen ------------------------------------------------------- Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara The only event dedicated to issues related to Linux enterprise solutions www.enterpriselinuxforum.com