libstdc++/6732: misaligned objects created by new
bkoz@gcc.gnu.org
bkoz@gcc.gnu.org
Thu Jul 4 03:18:00 GMT 2002
Synopsis: misaligned objects created by new
State-Changed-From-To: open->analyzed
State-Changed-By: bkoz
State-Changed-When: Wed Jul 3 22:51:48 2002
State-Changed-Why:
I'm not quite convinced that this is a C++ library problem.
It seems like "C" also has the same issue.
Note that gcc-2.96, others also have the same behavior.
#include <iostream>
struct vec4
{
float x, y, z, w;
} __attribute__((__aligned__(16)));
int main()
{
std::allocator<vec4> a;
for (int i = 0; i < 10; ++i)
{
vec4* p = new vec4;
std::cerr << reinterpret_cast<void*>(p) << " ";
std::cerr << reinterpret_cast<std::size_t>(p) % 16 << " ";
std::cerr << std::endl;
}
for (int i = 0; i < 10; ++i)
{
vec4* p = reinterpret_cast<vec4*>(malloc(sizeof(vec4)));
std::cerr << reinterpret_cast<void*>(p) << " ";
std::cerr << reinterpret_cast<std::size_t>(p) % 16 << " ";
std::cerr << std::endl;
}
}
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6732
More information about the Gcc-bugs
mailing list