[llvm-bugs] [Bug 40230] New: padding in nested std::pair

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jan 4 12:52:28 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40230

            Bug ID: 40230
           Summary: padding in nested std::pair
           Product: libc++
           Version: 7.0
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: maxime.arthaud at nasa.gov
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Hi everyone,

I am getting a weird padding at the beginning of a std::pair.

See the following example:

#include <cstdio>
#include <utility>

int main() {
  std::pair< std::pair< char, char >, char > p;
  printf("%lu %p %p\n", sizeof(p), &p, &p.first);
  return 0;
}

Output:
4 0x7fffffffe738 0x7fffffffe739

There is an additional byte at the beginning of the pair, for no reason. This
is not really a bug, but is worth improving.

It causes crashes in boost::container::flat_map, see
https://github.com/boostorg/container/issues/97

Please note that this only happens on FreeBSD.

System: FreeBSD 12.0
Compiler: Clang 6.0.1 (default compiler on FreeBSD)
libc++: master branch on Github

I'm pretty sure this is related to https://reviews.llvm.org/D25389
The base class __non_trivially_copyable_base introduces the padding. I don't
understand why Empty Base Optimization doesn't work in that case.

To reproduce this, I used the following virtual machine:
https://download.freebsd.org/ftp/releases/VM-IMAGES/12.0-RELEASE/amd64/Latest/

Upstream issue in IKOS: https://github.com/NASA-SW-VnV/ikos/issues/22

-- 
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/20190104/2d1debb4/attachment.html>


More information about the llvm-bugs mailing list