LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-10-2006, 06:55 AM   #1
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Rep: Reputation: 15
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
 
Old 01-11-2006, 05:21 AM   #2
llmmix
Member
 
Registered: Jun 2005
Posts: 73

Rep: Reputation: 15
gcc 4.0.2 works fine here.
 
Old 01-11-2006, 06:37 AM   #3
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Original Poster
Rep: Reputation: 15
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
 
Old 11-17-2008, 03:57 PM   #4
lindylex
Member
 
Registered: Mar 2007
Posts: 192

Rep: Reputation: 17
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
 
Old 06-10-2009, 04:06 AM   #5
mwadoublestar
LQ Newbie
 
Registered: Apr 2006
Posts: 6

Rep: Reputation: 0
Quote:
Originally Posted by stephenwalter View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tai64nlocal.c:55: error: dereferencing pointer to incomplete type ExCIA Linux - General 1 03-31-2009 09:49 AM
list<type> how can I make type be a pointer? exodist Programming 2 06-06-2005 08:40 AM
What is the warning: passing arg 3 of `pthread_create' from incompatible pointer type wallwaters Linux - Software 3 06-01-2005 08:30 AM
"dereferencing `void *' pointer" but how else?!? f0rmula Programming 6 03-24-2005 05:32 AM
C error "dereferencing pointer to incomplete type" lucs Slackware 6 02-21-2005 09:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration