[llvm-bugs] [Bug 35028] New: Clang does not use the strictest alignas in templates
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Oct 21 20:52:23 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=35028
Bug ID: 35028
Summary: Clang does not use the strictest alignas in templates
Product: clang
Version: 5.0
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: billy.oneal at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
template<class X>
struct alignas(X) alignas(unsigned long) alignas(unsigned int) queue {
unsigned long a;
unsigned int b;
// X suffix[];
};
template struct queue<unsigned short>;
On Godbolt: https://godbolt.org/g/7MUaSE
2 : <source>:2:8: error: requested alignment is less than minimum alignment of
8 for type 'queue<unsigned short>'
struct alignas(X) alignas(unsigned long) alignas(unsigned int) queue {
^
8 : <source>:8:17: note: in instantiation of template class 'queue<unsigned
short>' requested here
template struct queue<unsigned short>;
^
1 error generated.
Compiler exited with result code
N4687 10.6.2 [dcl.align]/4 says:
The alignment requirement of an entity is the strictest nonzero alignment
specified by its alignment-specifiers, if any; otherwise, the
alignment-specifiers have no effect.
Therefore, even though alignas(X) requests an alignment of 2, less than the
minimum of 8, the following alignas which requests an alignment of 8 should
make the overall alignment request be for 8.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171022/ac1031b1/attachment.html>
More information about the llvm-bugs
mailing list