This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/53900] [regression] Too optimistic on a alignment assert


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53900

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-09 16:18:58 UTC ---
Well, I suggest you instead do

struct Foo
{
  float array[4];
  Foo()
  {
    std::cout << array << "\n";
    // check the object is really aligned
    if (std::ptrdiff_t(array) & std::ptrdiff_t(0xf)) != 0)
      assert (false);
    <...code assuming array is aligned...>
  }
};

and the compiler will figure out that array is aligned in code dominated
by the alignment check.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]