This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53900] [regression] Too optimistic on a alignment assert
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 09 Jul 2012 16:18:58 +0000
- Subject: [Bug c++/53900] [regression] Too optimistic on a alignment assert
- Auto-submitted: auto-generated
- References: <bug-53900-4@http.gcc.gnu.org/bugzilla/>
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.