Launchpad has imported 2 comments from the remote bug at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60581.

If you reply to an imported comment from within Launchpad, your comment
will be sent to the remote bug automatically. Read more about
Launchpad's inter-bugtracker facilities at
https://help.launchpad.net/InterBugTracking.

------------------------------------------------------------------------
On 2014-03-19T09:07:48+00:00 Rafał Mużyło wrote:

The problem is described here: https://bugs.gentoo.org/show_bug.cgi?id=505026
The code to trigger comes from a launchpad bug: 
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1072650

As you may notice, it's acros distros and affects many compiler versions
(confirmed for 4.6.3 on ubuntu, 4.7.3 and 4.8.2 on Gentoo).

Following code (AFAICT) violates strict aliasing rules:
#include <stdio.h>

struct psuedo_hdr
{
  int saddr;
  int daddr;
  char zero;
  char protocol;
  short len;
} __attribute__((packed));

int main()
{
  unsigned int i;
  unsigned int sum = 0;
  struct psuedo_hdr hdr;

  hdr.saddr = 0xaabbccdd;
  hdr.daddr = 0x11223344;
  hdr.zero = 0;
  hdr.protocol = 6;
  hdr.len = 2;
  for (i = 0; i < sizeof(hdr); i += 2)
    sum += *(short *)((char *)(&hdr) + i);
  printf("0x%x\n", sum);
  return 0;
}

however, '-O2 -Wall' doesn't result in the strict aliasing warning.

Reply at: https://bugs.launchpad.net/ubuntu/+source/gcc-
defaults/+bug/1072650/comments/3

------------------------------------------------------------------------
On 2014-03-19T10:00:27+00:00 Rguenth wrote:

The strict-aliasing warnings are broken - they are too easily to silence
(the (char *) cast for example).  Generally warning for TBAA violations
is very hard if you want to avoid gazillions of false positives or
gazillions of false negatives.  The present warning code delivers
neither :/

Reply at: https://bugs.launchpad.net/ubuntu/+source/gcc-
defaults/+bug/1072650/comments/5


** Changed in: gcc-defaults
       Status: Unknown => Confirmed

** Changed in: gcc-defaults
   Importance: Unknown => Medium

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1072650

Title:
  gcc doesn't isssue a strict aliasing warning on a code that seems to
  break it

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc-defaults/+bug/1072650/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to