[llvm-bugs] [Bug 32006] New: pointer_traits for __wrap_iter types sometimes produces nonsense

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Feb 18 12:52:41 PST 2017


            Bug ID: 32006
           Summary: pointer_traits for __wrap_iter types sometimes
                    produces nonsense
           Product: libc++
           Version: 4.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arthur.j.odwyer at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

This is more of an enhancement request than a bug, I think, because I don't see
anywhere that the Standard actually specifies what counts as a "pointer-like
type". However, here's the problem:

In general, it is true (by accident, not by specification) that

    pointer_traits<T>::element_type ==

But when you set T == std::vector<int>::iterator, you find that

    pointer_traits<T>::element_type == T::pointer_type


This is because for any type of the form X<Y>, the standard mandates that
pointer_traits<X<Y>>::element_type == Y. So when you feed in
std::vector<int>::iterator a.k.a. __wrap_iter<int*>, element_type comes out as

Additionally, this nerfs the libc++ extension function "__to_raw_pointer" for
contiguous iterators.
    int *p = std::__to_raw_pointer(myvector.end());
does not compile.

This could be resolved by
- closing as NOTABUG since iterator types are not "pointer-like"; or
- adding an element_type typedef to libc++'s __wrap_iter; or
- adding a partial specialization for pointer_traits<__wrap_iter<Y>>.

The discussion that led to this "discovery" was

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/20170218/14987c1e/attachment.html>

More information about the llvm-bugs mailing list