LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   gcc 4.0.0 warning: dereferencing type-punned pointer will break strict-aliasing rules (http://www.linuxquestions.org/questions/programming-9/gcc-4-0-0-warning-dereferencing-type-punned-pointer-will-break-strict-aliasing-rules-401559/)

stephenwalter 01-10-2006 06:55 AM

gcc 4.0.0 warning: dereferencing type-punned pointer will break strict-aliasing rules
 
Hello all,
Just need this clarification. In my program i have a user defined function with prototype myfunc(void** ptr)
and consider for example i call it like this

char * name;
myfunc((void**)&name);

I get this compilation warning wherever i do this

warning: dereferencing type-punned pointer will break strict-aliasing rules

I just want to know why , because the same program run on gcc 2.96 does not produce the same warning , when i run it in gcc 4.0.0. i get this warning , i also need to find a way to fix this issue. Any help in this regard would be great.

Regards,
S.Suresh Stephen

llmmix 01-11-2006 05:21 AM

gcc 4.0.2 works fine here.

stephenwalter 01-11-2006 06:37 AM

Hello,
Thanks for your reply , but i found that this warning was being raised due to strict aliasing rules in the gcc 4.0.0. compiler and also these warnings can be supressed by adding a compile option -fno-strict-aliasing to my makefiles (and that really solves my issue) , maybe those warnings are supressed by default in gcc 4.0.2 compiler that you are using , anyway thanks again for your reply.

Regards,
S.Suresh Stephen

lindylex 11-17-2008 03:57 PM

stephenwalter, thanks I was getting worried when I kept on seeing the same error.

This is version of Glib 2.4.8 I am installing on Debian Etch.

http://ftp.acc.umu.se/pub/GNOME/sour...b-2.4.8.tar.gz

mwadoublestar 06-10-2009 04:06 AM

Quote:

Originally Posted by stephenwalter (Post 2039526)
Hello all,
Just need this clarification. In my program i have a user defined function with prototype myfunc(void** ptr)
and consider for example i call it like this

char * name;
myfunc((void**)&name);

I get this compilation warning wherever i do this

warning: dereferencing type-punned pointer will break strict-aliasing rules

I just want to know why , because the same program run on gcc 2.96 does not produce the same warning , when i run it in gcc 4.0.0. i get this warning , i also need to find a way to fix this issue. Any help in this regard would be great.

Regards,
S.Suresh Stephen

-fstrict-aliasing and -Wstrict-aliasing must be enable in Makefile. Remove them from Makefile. Or remove Werror from Makefile


All times are GMT -5. The time now is 10:04 PM.