[llvm-bugs] [Bug 35438] New: std::bitset::bitset(unsigned long long) does not zero unused bits

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 27 08:01:12 PST 2017


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

            Bug ID: 35438
           Summary: std::bitset::bitset(unsigned long long) does not zero
                    unused bits
           Product: libc++
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tebbi at chromium.org
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

As per the standard, the std::bitset<n>::bitset(unsigned long long x)
constructor should only take the lowest n bits from the argument, however, the
libc++ implementation stores the argument unchanged in its backing store, which
can be observed by the to_ulong() member function.

Example:

std::bitset<8> x(10000000);
printf("%zu\n", x.to_ulong());

This should output 255, but it outputs 10000000.
Also, this behavior is different from libstdc++, which is standard compliant in
this case.

-- 
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/20171127/9bfeab89/attachment.html>


More information about the llvm-bugs mailing list