Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignments to components of fields within a struct array are optimized away by the runtime optimizer #834

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ TESTSUITE ( and-or-not-synonyms aastep arithmetic array array-derivs array-range
blackbody blendmath breakcont
bug-array-heapoffsets
bug-locallifetime bug-outputinit bug-param-duplicate bug-peep
bug-struct-assign
cellnoise closure closure-array color comparison
compile-buffer
component-range const-array-params const-array-fill
Expand Down
3 changes: 3 additions & 0 deletions testsuite/bug-struct-assign/ref/out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Compiled test.osl -> test.oso
c[0].rgb: 1 2 3
(-1 2 3) == (-1 2 3)
4 changes: 4 additions & 0 deletions testsuite/bug-struct-assign/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python

command = testshade("-g 1 1 test")
failureok = failstage2 # diff should fail, bug still exists!
19 changes: 19 additions & 0 deletions testsuite/bug-struct-assign/test.osl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Assignemnt to indexed struct element currently broken

struct custom {
color rgb;
};

shader test ()
{
custom c[2];
c[0].rgb = color(1,2,3);

// Broken:
c[0].rgb[0] = -c[0].rgb[0];

// Works:
c[1].rgb = color(-c[0].rgb[0], c[0].rgb[1], c[0].rgb[2]);

printf("(%g) == (%g)\n", c[0].rgb, c[1].rgb);
}
10 changes: 8 additions & 2 deletions testsuite/runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
hardfail = 0.01
failpercent = 0.02

# Fail on stage1 : oslc
failstage1 = 1
# Fail on stage2 : diff / ref comaprison
failstage2 = 2

image_extensions = [ ".tif", ".tx", ".exr", ".jpg", ".png", ".rla",
".dpx", ".iff", ".psd" ]

Expand Down Expand Up @@ -232,7 +237,7 @@ def runtest (command, outputs, failureok=0, failthresh=0, failpercent=0) :

for sub_command in command.split(splitsymbol):
cmdret = subprocess.call (sub_command, shell=True, env=test_environ)
if cmdret != 0 and failureok == 0 :
if cmdret != 0 and failureok != failstage1 :
print "#### Error: this command failed: ", sub_command
print "FAIL"
return (1)
Expand All @@ -257,7 +262,8 @@ def runtest (command, outputs, failureok=0, failthresh=0, failpercent=0) :
else :
# anything else
cmpresult = 0 if filecmp.cmp (out, testfile) else 1
if cmpresult == 0 :
# cmpresult should be 0 (no error), unless expected to fail the diff
if cmpresult == 0 if failureok != failstage2 else cmpresult != 0:
ok = 1
break # we're done

Expand Down