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

From: Jun Kuriyama <kuriyama_at_imgsrc.co.jp>
Date: Mon, 28 Jul 2003 10:35:22 +0900
At Mon, 28 Jul 2003 00:30:35 +0000 (UTC),
kuriyama wrote:
> Is this caused by -oS option?

Grrr, of course this should be s/-oS/-Os/.

These warnings are caused from DROP_GIANT() macro.  By tracking this
down, actual source is __PCPU_GET() macro (line: 115) in
sys/i386/include/pcpu.h.

		__result = *(__pcpu_type(name) *)&__i;

To test this with simplified code:

-----
% cat test.c
struct T {
  int a;
};

void
test()
{
  struct T* c;
  int __i = 0;
  c = *(struct T* *)&__i;
}
% cc -c -Os -Wall test.c
test.c: In function `test':
test.c:11: warning: dereferencing type-punned pointer will break strict-aliasing rules
-----

__PCPU_GET() macro seems to be harmless if -Os is not used or
__pcpu_type() returns actual type rather than pointer.

What should we do?


-- 
Jun Kuriyama <kuriyama_at_imgsrc.co.jp> // IMG SRC, Inc.
             <kuriyama_at_FreeBSD.org> // FreeBSD Project
Received on Sun Jul 27 2003 - 16:35:26 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:16 UTC