[llvm-bugs] [Bug 34664] New: variant uses "unsigned int" to store index, making it bigger than necessary
llvm-bugs at lists.llvm.org
Tue Sep 19 00:14:17 PDT 2017
Bug ID: 34664
Summary: variant uses "unsigned int" to store index, making it
bigger than necessary
OS: MacOS X
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: jonathan.sauer at gmx.de
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
In the following program, the size of "v" could be 2 (1 byte for the char, 1
byte for the index). Instead it is 8:
using v = std::variant<char>;
static_assert(sizeof(v) == 8);
This is because currently variant stores its index as an unsigned int even when
a smaller type would suffice, wasting a fair amount of memory.
variant should use the smallest possible integer type to store its index.
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-bugs