Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Jul 2003 10:35:22 +0900
From:      Jun Kuriyama <kuriyama@imgsrc.co.jp>
To:        Current <freebsd-current@FreeBSD.org>
Subject:   Re: dereferencing type-punned pointer will break strict-aliasing rules
Message-ID:  <7mvftnv3fp.wl@black.imgsrc.co.jp>
In-Reply-To: <7mwue3v6gf.wl@black.imgsrc.co.jp>
References:  <7mwue3v6gf.wl@black.imgsrc.co.jp>

next in thread | previous in thread | raw e-mail | index | archive | help
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@imgsrc.co.jp> // IMG SRC, Inc.
             <kuriyama@FreeBSD.org> // FreeBSD Project



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7mvftnv3fp.wl>