-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Labels
ABIApplication Binary InterfaceApplication Binary Interfacelibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
It strange issue, but there are CppCon video about libc++ shipped with clang:
https://www.youtube.com/watch?v=iw8hqKftP4I
And in first 9 minutes speaker says, that this code should compile on clang with libc++:
template<typename V, typename E>
struct EX {
union U {
[[no_unique_address]] V v;
[[no_unique_address]] E e;
};
[[no_unique_address]] U u_;
bool has_val_;
};
struct mystruct {
int x;
bool y;
char z;
};
static_assert(sizeof(EX<mystruct, int>) == 8); // 12 in realityBut its not. Sizeof == 8, and i agree with compiler here
I also checked with std::expected itself:
#include <expected>
struct mystruct {
int x;
bool y;
char z;
};
mystruct foo();
std::expected<mystruct, int> compute() {
return foo();
}
static_assert(sizeof(std::expected<mystruct, int>) == 12); // again, 12
https://godbolt.org/z/jPfbMqchW
A talk generally good, but this first part (9 minutes) confuses me.
Metadata
Metadata
Assignees
Labels
ABIApplication Binary InterfaceApplication Binary Interfacelibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!