<html>
    <head>
      <base href="http://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Address space 8388355 should not be generic in C++"
   href="http://bugs.llvm.org/show_bug.cgi?id=32662">32662</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Address space 8388355 should not be generic in C++
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>pkeir@outlook.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18286" name="attach_18286" title="A MWE similar to the example described">attachment 18286</a> <a href="attachment.cgi?id=18286&action=edit" title="A MWE similar to the example described">[details]</a></span>
A MWE similar to the example described

LLVM supports address space annotation such as:

__attribute__((address_space(42))) int *p;

A most useful aspect of their functionality is knowing that such pointers
cannot be converted to one another. For example, this static assert passes:

using pt1 = __attribute__((address_space(1))) int *;
using pt2 = __attribute__((address_space(2))) int *;
static_assert(!std::is_convertible<pt0,pt1>::value,"");

Though this functionality has many uses within standard C++, LLVM's OpenCL
implementation also uses this feature. Since around Clang 3.9, however, an
aspect particular to OpenCL appears when compiling C++. This aspect should
rather rely on the user specifying explicitly that OpenCL is to be compiled;
perhaps via "-x cl -cl-std=CL2.0".

Address space 8388355 is used by Clang to implement the generic address space
added in OpenCL 2.0. In C++, converting a pointer targeting address space
8388355 should behave the same as pointers targeting other address spaces: it
should not be convertible.

As a concrete example, the following should not produce an error, but as of
Clang 3.9 it does:

using pt1       = __attribute__((address_space(1)))       int *;
using pt2       = __attribute__((address_space(2)))       int *;
using pt8388355 = __attribute__((address_space(8388355))) int *;
static_assert(!std::is_convertible<pt0,pt8388355>::value,"");
static_assert(!std::is_convertible<pt1,pt8388355>::value,"");</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>