https://bugs.llvm.org/show_bug.cgi?id=48286
Bug ID: 48286
Summary: Not treating unions with at least one literal member
as literal
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++11
Assignee: unassignedclangb...@nondot.org
Reporter: ant.bikin...@gmail.com
CC: blitzrak...@gmail.com, dgre...@apple.com,
erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
richard-l...@metafoo.co.uk
Clang fails to compile the following code:
std::optional<NonLiteral> unpopulated{};
The reduced example is:
template <typename T>
struct A {
union {
char c = 0;
T t;
};
};
constexpr A<NonLiteral> unpopulated{};
The error clang emits is:
error: constexpr variable cannot have non-literal type 'const A<NonLiteral>'
constexpr A<NonLiteral> unpopulated{};
^
note: 'A<NonLiteral>' is not literal because it has data member '' of
non-literal type 'union (anonymous union at ...)'
A relevant section from the Standard (unless I'm missing another one):
[6.8.1.10]
A type is a literal type if it is:
- ...
- if it is a union, at least one of its non-static data members is of
non-volatile literal type, and ...
gcc succeeds to compile this example.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs