Bug#561691: Please declare struct sockaddr and sockaddr_storage as may_alias

2009-12-27 Thread Aurelien Jarno
On Sun, Dec 27, 2009 at 01:35:43AM +0100, Juliusz Chroboczek wrote:
  There is no risk of breakage in optimised code with -O2 or more.
 
 For my education -- could you please explain why?  (No need to quote the
 C99 standard, just give me the intuition.)
 

It is a false positive due to the fact level 2 is only an approximation
with a lot of false positive. The punn+dereference pattern is handled
correctly by GCC, that's why it does not trigger a warning in level 3
which is more precise.

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net



-- 
To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#561691: Please declare struct sockaddr and sockaddr_storage as may_alias

2009-12-26 Thread Juliusz Chroboczek
 There is no risk of breakage in optimised code with -O2 or more.

For my education -- could you please explain why?  (No need to quote the
C99 standard, just give me the intuition.)

Juliusz



-- 
To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Processed: Re: Bug#561691: Please declare struct sockaddr and sockaddr_storage as may_alias

2009-12-25 Thread Debian Bug Tracking System
Processing commands for cont...@bugs.debian.org:

 severity 561691 wishlist
Bug #561691 [libc6-dev] Please declare struct sockaddr and sockaddr_storage as 
may_alias
Ignoring request to change severity of Bug 561691 to the same value.
 tag 561691 + wontfix
Bug #561691 [libc6-dev] Please declare struct sockaddr and sockaddr_storage as 
may_alias
Added tag(s) wontfix.
 thanks
Stopping processing here.

Please contact me if you need assistance.

Debian bug tracking system administrator
(administrator, Debian Bugs database)


-- 
To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#561691: Please declare struct sockaddr and sockaddr_storage as may_alias

2009-12-25 Thread Aurelien Jarno
severity 561691 wishlist
tag 561691 + wontfix
thanks

On Sat, Dec 19, 2009 at 06:03:48PM +0100, Juliusz Chroboczek wrote:
 Package: libc6-dev
 Version: 2.10.2-2
 
 Type punning between pointers to struct sockaddr, struct sockaddr_storage
 and sockaddr_in(6) is explicitly required by the sockets interface.  For
 example, RFC 3493 Section 3.8 gives the following example:
 
   if (bind(s, (struct sockaddr *) sin6, sizeof(sin6)) == -1)
 
 Unfortunately, gcc-4.4 with -fstrict-aliasing=2 complains on this kind
 of code.  This may potentially break in code optimised with -O2 or greater
 (it probably doesn't, though, since most of the code that triggers this
 warning doesn't actually violate the C99 aliasing restrictions).

gcc 4.4 with -Wstrict-aliasing=3 does not emit a warning on that. 
Moreover quoting the gcc manual:

| Level 2: Aggressive, quick, not too precise.  May still have many false
| positives (not as many as level 1 though), and few false negatives (but
| possibly more than level 1).  Unlike level 1, it only warns when an
| address is taken.  Warns about incomplete types.  Runs in the frontend
| only.
|
| Level 3 (default for -Wstrict-aliasing): Should have very few false
| positives and few false negatives.  Slightly slower than levels 1 or 2
| when optimization is enabled.  Takes care of the common punn+dereference
| pattern in the frontend: *(int*)some_float.  If optimization is
| enabled, it also runs in the backend, where it deals with multiple
| statement cases using flow-sensitive points-to information.  Only warns
| when the converted pointer is dereferenced.  Does not warn about
| incomplete types.

This is clearly what happens here, gcc emits a false positive. You 
should use -Wstrict-aliasing=3, which is actually the default value.
There is no risk of breakage in optimised code with -O2 or more.


 I suggest that the definitions of struct sockaddr and struct sockaddr_storage
 should be equipped with
 
   __attribute__ ((may_alias))
 
 Juliusz
 
 
 
 -- 
 To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org
 with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
 
 

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net



-- 
To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#561691: Please declare struct sockaddr and sockaddr_storage as may_alias

2009-12-19 Thread Juliusz Chroboczek
Package: libc6-dev
Version: 2.10.2-2

Type punning between pointers to struct sockaddr, struct sockaddr_storage
and sockaddr_in(6) is explicitly required by the sockets interface.  For
example, RFC 3493 Section 3.8 gives the following example:

  if (bind(s, (struct sockaddr *) sin6, sizeof(sin6)) == -1)

Unfortunately, gcc-4.4 with -fstrict-aliasing=2 complains on this kind
of code.  This may potentially break in code optimised with -O2 or greater
(it probably doesn't, though, since most of the code that triggers this
warning doesn't actually violate the C99 aliasing restrictions).

I suggest that the definitions of struct sockaddr and struct sockaddr_storage
should be equipped with

  __attribute__ ((may_alias))

Juliusz



-- 
To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org