<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - OpenCL incorrectly accepts implicit address space conversion with ternary operator"
   href="http://llvm.org/bugs/show_bug.cgi?id=19957">19957</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>OpenCL incorrectly accepts implicit address space conversion with ternary operator
          </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>normal
          </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>Matthew.Arsenault@amd.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12616" name="attach_12616" title="Testcase">attachment 12616</a> <a href="attachment.cgi?id=12616&action=edit" title="Testcase">[details]</a></span>
Testcase

When there is an implicit address space conversion in a ternary operator, in
some cases it is incorrectly accepted. It produces a warning about mismatched
pointer types in some cases, but is the correct error about changing the
address space of the pointer in others.

An example of the broken case is:

kernel void implicit_cast_private(global int* gint, local int* lint, int cond)
{
    int *ptr = cond ? gint : lint;


Which is merely a warning: pointer type mismatch ('__global int *' and '__local
int *')

A similar case which correctly errors:

kernel void implicit_cast_local(global int* gint, local int* lint, int cond)
{
    local int *ptr = cond ? gint : lint;
}

error: initializing '__local int *' with an expression of type 'void *' 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>