File: func_template_array_7.ispc

package info (click to toggle)
ispc 1.28.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 97,620 kB
  • sloc: cpp: 77,067; python: 8,303; yacc: 3,337; lex: 1,126; ansic: 631; sh: 475; makefile: 17
file content (15 lines) | stat: -rw-r--r-- 497 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Check out of bounds warning for arrays inside templates.
// RUN: %{ispc} --target=host --nowrap --nostdlib %s 2>&1 | FileCheck %s

// CHECK-COUNT-1: Warning: Array index "8" may be out of bounds for 8 element array.

template <int C> void testArrayAccess(uniform int ret[], uniform int arr[])
{
    uniform int O[C] = {0};
    ret[0] = O[arr[0] % C]; // Valid access
    ret[1] = O[C]; // Non-Valid access
}

void test(uniform int ret[], uniform int arr[]) {
    testArrayAccess<8>(ret, arr);
}