This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC warnings question


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]