// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage

shader
test_varying_out_of_bounds_index_string (output color Cout = color(0,0,0))
{
    // Test array referencing with varying index
    string rarray[3] = { "1", "2", "3" };
    string garray[3] = { "2", "4", "6" };
    
    
    // out of bounds, should segfault if accessed accidentally
    int varyingIndex = 2000000000;

    string indirectR = "1";
    string indirectG = "1";
    string indirectB = "1";
    
    if (int(P[0]*256)%2 == 0) {
        varyingIndex = int(clamp(P[0]*3, 0, 2));
    
        indirectR = rarray[varyingIndex];
        indirectG = garray[varyingIndex];
    }
    
    Cout = color(stoi(indirectR)/10.0,stoi(indirectG)/10.0,float(varyingIndex)/3.0);
}
