gcc 4.0.0 warning: dereferencing type-punned pointer will break strict-aliasing rules
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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
Last edited by mwadoublestar; 06-10-2009 at 04:43 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.