Bug 60202 - < 128 alignment for vector<T> data where T has a member with alignas(128)
Summary: < 128 alignment for vector<T> data where T has a member with alignas(128)
Status: RESOLVED DUPLICATE of bug 36159
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-14 18:12 UTC by ilja.honkonen
Modified: 2016-01-31 00:11 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-redhat-linux
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
source (373 bytes, text/x-c++src)
2014-02-14 18:13 UTC, ilja.honkonen
Details
saved temp (88.83 KB, text/plain)
2014-02-14 18:13 UTC, ilja.honkonen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ilja.honkonen 2014-02-14 18:12:35 UTC
gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-isl=/builddir/build/BUILD/gcc-4.8.2-20131212/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.2-20131212/obj-x86_64-redhat-linux/cloog-install --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Säiemalli: posix
gcc-versio 4.8.2 20131212 (Red Hat 4.8.2-7) (GCC)

Command line: g++ -std=c++0x -W -Wall -Wextra -pedantic -O3 testi.cpp -o testi
where testi.cpp is http://ideone.com/XpgXyG and is also attached.

No compiler output to stdout.

Example of program output:

Address 0x7fffeb791c80 is 128 bytes aligned.
Address 0x7fffeb791d00 is 256 bytes aligned.
Address 0xafa010 is 16 bytes aligned.
Address 0xafa0a0 is 32 bytes aligned.
Address 0xafa1b0 is 16 bytes aligned.
Address 0xafa6c0 is 64 bytes aligned.

Shouldn't all of the printed addresses be at least 128 byte aligned or compilation should fail?
Comment 1 ilja.honkonen 2014-02-14 18:13:23 UTC
Created attachment 32137 [details]
source
Comment 2 ilja.honkonen 2014-02-14 18:13:53 UTC
Created attachment 32138 [details]
saved temp
Comment 3 Andrew Pinski 2014-02-14 18:25:31 UTC
We don't have a operator new which supports alignas yet.
http://listengine.tuxfamily.org/lists.tuxfamily.org/eigen/2014/02/msg00033.html
Comment 4 Martin Sebor 2016-01-31 00:11:05 UTC
I believe this can be classified as a duplicate of bug 36159, which asks to add a warning pointing out this loophole in C++.

The underlying problem is that standard containers like vector are required to use the standard allocator which in turn is required to use the default operator new to allocate memory, which provides no interface to specify the alignment of the type being allocated.

If the C++ proposal for the Dynamic Memory Allocation For Over-aligned Data is accepted and implemented then it will become possible to use standard containers with overaligned types:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0035r0.html

*** This bug has been marked as a duplicate of bug 36159 ***