Oracle® Solaris Studio 12.4: C User's Guide

Exit Print View

Updated: March 2015
 
 

2.11.17 no_side_effect

#pragma no_side_effect(funcname[, funcname…])

funcname specifies the name of a function within the current translation unit. The function must be declared with a prototype or empty parameter list prior to the pragma. The pragma must be specified prior to the function’s definition. For the named function, funcname, the pragma declares that the function has no side effects of any kind and returns a result value that depends only on the passed arguments. In addition, funcname and any called descendants behave as follows:

  • Do not access for reading or writing any part of the program state visible in the caller at the point of the call.

  • Do not perform I/O.

  • Do not change any part of the program state not visible at the point of the call.

The compiler can use this information when doing optimizations using the function. If the function does have side effects, the results of executing a program that calls this function are undefined. The compiler takes advantage of this information at optimization level of 3 or above.