Menu

#227 Args to SL functions should not be writable

non_fatal
open
nobody
7
2012-09-20
2007-01-07
No

Arguments to shading language functions are writable - this should not be the case. As stated in the RISpec:

"Function parameters are passed by reference; in other words, parameters are not copied into private data areas of the function. Neverheless, function parameters are not writable unless specified with the output keyword."

So, I suppose doing something like

void test(float f)
{
f = 1;
}

Should result in a compile-time error (or at least, the creation of a temporary variable for f). aqsl fails to pick this up however.

The attached rib and shaders demonstrate the problem. The left pane should be white, while the right pane should be grey (if aqsl will create temporaries), or alternatively, pass_by_ref.sl should fail to compile.

Discussion

  • Chris Foster

    Chris Foster - 2007-01-07
     
  • Chris Foster

    Chris Foster - 2007-01-07

    modifies an argument illegally

     
  • Chris Foster

    Chris Foster - 2007-01-07

    Logged In: YES
    user_id=1086736
    Originator: YES

    File Added: pass_by_ref.sl

     
  • Chris Foster

    Chris Foster - 2007-01-07

    Logged In: YES
    user_id=1086736
    Originator: YES

    File Added: pass_by_ref_output.sl

     
  • Chris Foster

    Chris Foster - 2007-01-07

    modifies an argument legally using the output keyword

     
  • Chris Foster

    Chris Foster - 2008-12-16

    This bug has just bitten an unsuspecting user - unsurprisingly the same issue exists with instanced shaders as well. For example, the following shader should fail to compile:

    surface illegal_parameter_modification(float f = 1)
    {
    f = 42;
    }

     

Log in to post a comment.