This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/67911] New: new expression fails to align overaligned types
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 09 Oct 2015 16:48:52 +0000
- Subject: [Bug c++/67911] New: new expression fails to align overaligned types
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67911
Bug ID: 67911
Summary: new expression fails to align overaligned types
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
C++ leaves it implementation-defined whether the new expression supports
overaligned types. The test case below shows that GCC's new accepts overligned
types without a diagnostic but doesn't align them correctly.
GCC should either issue a diagnostic when a new expression is invoked with a
type whose alignment it cannot satisfy or it should satisfy it. The
implementation choice should also be documented in the manual.
$ cat a.cpp && /g++ -Wall -Wextra -O2 a.cpp && ./a.out
extern "C" int printf (const char*, ...);
struct __attribute__ ((aligned (32))) X { char a [32]; };
int main ()
{
X *p = new X ();
if (reinterpret_cast<unsigned long>(p) & (alignof (X) - 1))
printf ("%p not %lu-byte aligned\n", p, alignof (X));
}
0x1c81010 not 32-byte aligned