[llvm-bugs] [Bug 39183] New: tuple comparison operators return true for tuples of different sizes

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 4 13:32:35 PDT 2018


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

            Bug ID: 39183
           Summary: tuple comparison operators return true for tuples of
                    different sizes
           Product: libc++
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tonyelewis at hotmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

The following compiles cleanly under `clang++ -stdlib=libc++ -S a.cpp` :


#include <tuple>

static_assert( std::tuple<int>{ 1 } == std::tuple<int, int>{ 1, 2 }, "" );
static_assert( std::tuple<int>{ 0 } != std::tuple<int, int>{ 1, 2 }, "" );
static_assert( std::tuple<int>{ 0 } <  std::tuple<int, int>{ 1, 2 }, "" );
static_assert( std::tuple<int>{ 2 } >= std::tuple<int, int>{ 1, 2 }, "" );


..demonstrating that these comparison operators are returning true for pairs of
tuples of different sizes. This feels particularly problematic in the case of
operator==().

Under "tuple.rel", the standard says that these operators require
`sizeof...(TTypes) == sizeof...(UTypes)`, though I must confess I don't know
whether the standard mandates detection and reporting of violations of
requirements like these. Either way, I think it'd be very much better to do so
in this case.

I can reproduce this on Godbolt with "clang version 8.0.0 (trunk 343649)" (and
Clangs 6 and 7).

Thanks very much for all work on libc++.

-- 
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/20181004/99068928/attachment.html>


More information about the llvm-bugs mailing list