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: "gael.guennebaud at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 10 Jul 2012 11:09:16 +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 #4 from Gael Guennebaud <gael.guennebaud at gmail dot com> 2012-07-10 11:09:16 UTC ---
Created attachment 27770
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27770
Another demonstration of the issue using std::vector
Note that when we declare:
__attribute__((aligned(16))) float array[4];
we request GCC to give us an aligned array, and we are not telling gcc that
array is aligned that is slightly different. I attached another example
demonstrating the problem:
a simple declaration like:
std::vector<Foo> vec(5);
generates unaligned arrays that are not caught by assertion because it has been
removed by gcc 4.7. Outputs are as follow:
$ g++-4.7 -m32 alignedassert.cpp && ./a.out
ctor 0xffdc58f0
copy 0x9f72008
copy 0x9f72018
copy 0x9f72028
copy 0x9f72038
copy 0x9f72048
ctor 0xffdc5900
g++-4.6 -m32 alignedassert.cpp && ./a.out
ctor 0xff8e19e0
copy 0x98e2008
a.out: alignedassert.cpp:18: Foo::Foo(const Foo&): Assertion
`(std::ptrdiff_t(array) % std::ptrdiff_t(16))==0' failed.
Aborted