[llvm-bugs] [Bug 34664] New: variant uses "unsigned int" to store index, making it bigger than necessary
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Sep 19 00:14:17 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34664
Bug ID: 34664
Summary: variant uses "unsigned int" to store index, making it
bigger than necessary
Product: libc++
Version: 5.0
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: enhancement
Priority: P
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:
#include <variant>
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...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170919/23f27b0c/attachment.html>
More information about the llvm-bugs
mailing list