<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 --- - Clang 3.4 release branch fail to build a opencl kernel with __constant pointer comparison with NULL."
   href="http://llvm.org/bugs/show_bug.cgi?id=18120">18120</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang 3.4 release branch fail to build a opencl kernel with __constant pointer comparison with NULL.
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </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>zhigang.gong@gmail.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>The opencl kernel is as below:

  typedef unsigned int uint;
  #define NULL (void*)0
  __kernel void
  null_kernel_arg(__global unsigned int *dst, __global unsigned int *
mask_global, __constant unsigned int* mask_const)
  {
    if(dst && mask_global == NULL && mask_const == NULL)
    {
      uint idx = (uint)get_global_id(0);
      dst[idx] = idx;
    }
  }

The clang version is on release_34 branch, the top is:
  commit a6c1850bcc67f297682115232a9b5ddb2b835541
  Author: Hans Wennborg <<a href="mailto:hans@hanshq.net">hans@hanshq.net</a>>
  Date:   Mon Dec 2 22:38:55 2013 +0000
      Mention clang-cl in the release notes
      git-svn-id:
<a href="https://llvm.org/svn/llvm-project/cfe/branches/release_34@196166">https://llvm.org/svn/llvm-project/cfe/branches/release_34@196166</a>
91177308-0d34-0410-b5e6-96231b3b80d8

  commit 85ad3893a967faf9c76571d0991acab7c9c6bf06
  Author: Bill Wendling <<a href="mailto:isanbard@gmail.com">isanbard@gmail.com</a>>
  Date:   Mon Dec 2 19:19:57 2013 +0000
      Merging r196114:
      ------------------------------------------------------------------------
      r196114 | joerg | 2013-12-02 08:09:34 -0800 (Mon, 02 Dec 2013) | 2 lines

The command to trigger this bug is as below:

gongzg@gongzg-ivb:~/git/fdo/build$ clang -cc1 -x cl -triple spir -emit-llvm -O0
null_kernel_arg.cl
null_kernel_arg.cl:8:22: warning: implicit declaration of function
'get_global_id' is invalid in C99
    uint idx = (uint)get_global_id(0);
                     ^
clang: /home/gongzg/git/llvm-3.2/llvm/lib/IR/Constants.cpp:1448: static
llvm::Constant *llvm::ConstantExpr::getCast(unsigned int, llvm::Constant *,
llvm::Type *): Assertion `CastInst::castIsValid(opc, C, Ty) && "Invalid
constantexpr cast!"' failed.
0  clang           0x0000000002196525 llvm::sys::PrintStackTrace(_IO_FILE*) +
37
1  clang           0x0000000002196963
2  libpthread.so.0 0x00007f4a67c92cb0
3  libc.so.6       0x00007f4a66ab4425 gsignal + 53
4  libc.so.6       0x00007f4a66ab7b8b abort + 379
5  libc.so.6       0x00007f4a66aad0ee
6  libc.so.6       0x00007f4a66aad192
7  clang           0x00000000020941e3
8  clang           0x0000000000870ba0
9  clang           0x0000000000952605
10 clang           0x000000000094ab3d
11 clang           0x0000000000953923
12 clang           0x000000000094b573
13 clang           0x00000000009439ad
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 93
14 clang           0x000000000091a6b9
clang::CodeGen::CodeGenFunction::EvaluateExprAsBool(clang::Expr const*) + 233
15 clang           0x000000000088d4a2
clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr(clang::Expr const*,
llvm::BasicBlock*, llvm::BasicBlock*) + 818
16 clang           0x000000000088d8fa
clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr(clang::Expr const*,
llvm::BasicBlock*, llvm::BasicBlock*) + 1930
17 clang           0x000000000088d8a3
clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr(clang::Expr const*,
llvm::BasicBlock*, llvm::BasicBlock*) + 1843
18 clang           0x000000000087a68d
clang::CodeGen::CodeGenFunction::EmitIfStmt(clang::IfStmt const&) + 541
19 clang           0x0000000000879aa7
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 583
20 clang           0x000000000087fe9b
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot) + 91
21 clang           0x000000000088c8b8
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 824
22 clang           0x000000000089811b
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl)
+ 795
23 clang           0x00000000008956f1
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl) + 241
24 clang           0x0000000000897336
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 774
25 clang           0x0000000000899dff
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 1215
26 clang           0x000000000084b2bf
27 clang           0x000000000084a867
28 clang           0x00000000009b99c3 clang::ParseAST(clang::Sema&, bool, bool)
+ 435
29 clang           0x0000000000849da2 clang::CodeGenAction::ExecuteAction() +
514
30 clang           0x00000000006c07c0 clang::FrontendAction::Execute() + 112
31 clang           0x000000000069db7d
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 925
32 clang           0x0000000000685100
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2880
33 clang           0x000000000067d37f cc1_main(char const**, char const**, char
const*, void*) + 687
34 clang           0x000000000068335e main + 9182
35 libc.so.6       0x00007f4a66a9f76d __libc_start_main + 237
36 clang           0x000000000067d009
Stack dump:
0.      Program arguments: clang -cc1 -x cl -triple spir -emit-llvm -O0
null_kernel_arg.cl
1.      <eof> parser at end of file
2.      null_kernel_arg.cl:4:1: LLVM IR generation of declaration
'null_kernel_arg'
3.      null_kernel_arg.cl:4:1: Generating code for declaration
'null_kernel_arg'
Aborted (core dumped)</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>