Consider the following code (godbolt): As you see, there is a function returning a large POD and then a function wrapping it into a std::optional. ...
Consider the following code (godbolt): As you see, there is a function returning a large POD and then a function wrapping it into a std::optional. ...
As we know, the compiler or the CPU may reorder the execution as they want, only if they follow the as-if rule. For example, if we have such a piece o ...
What is the reason the C++ standard allows(requires) compilers to optimize away calls to copy constructor(in certain cases), even though it might cont ...
After a little google search (for instance, site:eel.is "as if rule") I couldn't find a proper place where the so called "as if" rule is clearly state ...
In the documentation of std::memory_order on cppreference.com there is an example of relaxed ordering: Relaxed ordering Atomic operations tagged ...
Recently I've read things about abstract machine and as-if rule (What exactly is the "as-if" rule?), and the requirements on time complexity of standa ...
Why does the standard allow my compiler to apply copy elision even when it involves visible side effects, thus breaks the as-if rule? It is somehow p ...
There is a great question about the "as-if" rule in general, but I wonder if there are any exceptions when it comes to measuring time. Consider this ...
The "as-if rule" gives the compiler the right to optimize out or reorder expressions that would not make a difference to the output and correctness of ...
The "as-if" rule is covered by these rules: The least requirements on a conforming implementation are: Access to volatile objects are evalua ...
Is it possible to have a loop which has a zero execution time? I would think that even an empty loop should have an execution time since there is an o ...
In this example, will my_function(MY_CONSTANT) be evaluated at each iteration, or will it be stored automatically? Would this depend on the optimiza ...
The "as-if" rule basically defines what transformations an implementation is allowed to perform on a legal C++ program. In short, all transformations ...
As the title says: What exactly is the "as-if" rule? A typical answer one would get is: The rule that allows any and all code transformatio ...