<html>
    <head>
      <base href="https://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 - [C++4OpenCL] Fix use of address spaces with new/delete"
   href="https://bugs.llvm.org/show_bug.cgi?id=49191">49191</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[C++4OpenCL] Fix use of address spaces with new/delete
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>OpenCL
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>anastasia.stulova@arm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>anastasia.stulova@arm.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The behavior of address spaces for new/delete is unclear i.e is it allowed to
use new/delete in named address spaces and in generic? It might be more helpful
to allow named address spaces since generic has not been intended for
allocations, but however generic makes things easier because it avoids
duplication and the concrete address space can always be cast to it. Use of
constant address space doesn't seem to make sense at all since nothing can be
done with a read-only chunk of memory?

Another aspect to consider - how will address spaces aligned with the concept
of overloading i.e.

    - Declaring multiple new operators with different address spaces in the
same scope generates an error since overloading by the return type is not
allowed.
    - Declaring multiple delete operators differing by address spaces seems to
fail because C++ doesn't allow to overload it yet.

Currently if other than generic address spaces are used clang fails with
various compile-time errors. For example, there is an error a new returning
pointer in a  local address space is assigned to local address space pointer
even if the declaration of new has the address space too:

`class A {
public:

__local void* operator new(size_t);

};
__local A* a = new A;`

error: assigning 'A *' to '__local A *' changes address space of pointer</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>