strict-aliasing question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I thought I have understood the aliasing-rules. But what is wrong with this:

$ cat alias.cc
#include <memory>

struct Col
{
    short val;
};

void func()
{
  char arr[sizeof(Col)] __attribute__ ((aligned(__alignof__(Col))));
  new (arr) Col;
  ((Col*)arr)->~Col();          // line 12
}

$ /tools/pkg/gcc/4.4.1/bin/g++ -o alias.o -c alias.cc -Wall -O2
alias.cc: In function void func():
alias.cc:12: warning: dereferencing type-punned pointer will break
strict-aliasing rules


   Jörg

-- 
View this message in context: http://www.nabble.com/strict-aliasing-question-tp25326530p25326530.html
Sent from the gcc - Help mailing list archive at Nabble.com.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux