This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC warnings question
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Jonathan Wilson <jonwil at tpgi dot com dot au>
- Cc: gcc <gcc at gcc dot gnu dot org>
- Date: Tue, 13 Apr 2004 14:52:28 +0100
- Subject: Re: GCC warnings question
- Organization: Codesourcery LLC
- References: <407BA35B.2030206@tpgi.com.au>
Jonathan Wilson wrote:
Is there a way to turn off these 2 warnings:
warning: dereferencing type-punned pointer will break strict-aliasing rules
warning: `xxx' defined but not used
without turning anything else off?
And also, what does the first warning mean?
it means that code looks like you might be trying to do
foo (int *ptr)
{
short *first = (short *)ptr;
short s;
*ptr = 1;
s = *first;
}
which is undefined.
turn #1 off by casting via void
(short *)(void *)ptr
This does not change the undefinedness of your code.
turn #2 off with
int xxx __attribute((unused));
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk