title: two nearly identical calls, one works one fails
body: <p>I have these template functions for use inline on device with cuda</p>
  
  <pre><code>template &lt;class T&gt; __device__ inline T&amp; cmin(T&amp;a,T&amp;b){return (a&lt;b)?(a):(b);};
  template &lt;class T&gt; __device__ inline T&amp; cmax(T&amp;a,T&amp;b){return (a&gt;b)?(a):(b);};
  </code></pre>
  
  <p>In the code I have </p>
  
  <pre><code>cmin(z[i],y[j])-cmax(x[i],z[j])
  </code></pre>
  
  <p>for int arrays x,y,and z.  I get the error:</p>
  
  <blockquote>
    <p>error: no instance of function template "cmax" matches the argument list</p>
  
  <pre><code>      argument types are: (int, int)
  </code></pre>
  </blockquote>
  
  <p>I get the error for cmax but not cmin.  If I replace the cmax line with </p>
  
  <pre><code>#define cmax(a,b) ((a)&gt;(b))?(a):(b)
  </code></pre>
  
  <p>that works just fine, but I don't want #defines, they are problematic.  What the heck is going on here?</p>
  
  <p>EDIT:
  here is the full calling function.  times is typedef int.</p>
  
  <pre><code>__global__ void compute_integral_y_isums(times * admit, times * discharge, times * Mx, times * isums, ar_size N){
      // computes the sums for each j
      // blocks on j,
      // threads on i since we will be summing over i.
      // sumation over J should be handled by either a different kernel or on the cpu.
      ar_index tid = threadIdx.x;
      ar_index i = blockIdx.x;                       // summing for patient i 
      ar_index j = threadIdx.x; // across other patients j
      __shared__ times cache[threadsPerBlock];
  
    times Iy = 0;
      while(j&lt;N){
          // R code:  max(0,min(Mx[i],d3[j,'Discharge.time'])-max(d3[i,'Admission.time'],Mx[j]))
          times imin = cmin(Mx[i],discharge[j]);
          times imax = cmax(admit[i],Mx[j]);
          Iy += cmax(0,imin-imax);
          j += blockDim.x;
      }
      cache[tid] = Iy;
  
      __syncthreads(); 
      // reduce 
      /***REMOVED***/
  }
  </code></pre>