Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      C attribute: unsequenced, reproducible(since C23)

      From cppreference.com
      <c‎ |language‎ |attributes
       
       
       
       
      Attributes
      (C23)(C23)(deprecated)
      unsequenced
      (C23)
       

      Provides the compiler with information about the access of objects by a function such that certain properties of function calls can be deduced.

      Contents

      [edit]Syntax

      [[unsequenced]]
      [[__unsequenced__]]
      (1)
      [[reproducible]]
      [[__reproducible__]]
      (2)
      1) Indicates that a function iseffectless,idempotent,stateless, andindependent.
      2) Indicates that a function is effectless and idempotent.

      [edit]Explanation

      These attributes apply to a function declarator or to a type specifier that has a function type. The corresponding attribute is a property of the function type.

      [edit]Effectless

      An evaluation of a function call is effectless if any store operationthat is sequenced during the call is the modification of an object that synchronizes with the call; if additionally the operation is observable, all access to the object must be based on a unique pointer parameter of the function.

      [edit]Idempotent

      An evaluationE is idempotent if a second evaluation ofE can be sequenced immediately after the original one without changing the resulting value, if any, or the observable state of the execution.

      [edit]Stateless

      A functionF is stateless if any definition of an object of static or threadstorage duration inF or in a function that is called byF isconst but notvolatile qualified.

      [edit]Independent

      A functionF is independent if for any objectX that is observed by a call toFthrough an lvalue that is not based on a parameter of the call, all accesses toX in all calls toF during the same program execution observe the same value;otherwise if the access is based on a pointer parameter, there shall be a unique such pointer parameterP such that any access toX shall be to an lvalue that is based onP.

      An objectX is observed by a function call if both synchronize, ifX is not local to the call, ifX has a lifetime that starts before the function call, and if an access ofX is sequenced during the call; the last value ofX, if any, that is stored before the call is said to be the value ofX that is observed by the call.

      [edit]Notes

      These attributes exist for the purpose of compiler optimization.

      If a function is reproducible, multiple subsequent calls can be treated as a single call.

      If a function is unsequenced, multiple subsequent calls can be treated as a single call, and the calls can be parallelized and reordered arbitrarily.

      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/language/attributes/unsequenced&oldid=168505"

      [8]ページ先頭

      ©2009-2026 Movatter.jp