The C++ Programming Language 4th edition, page 225 reads: A compiler may reorder code to improve performance as long as the result is identical to that of the s
Yes, it is legal - if the compiler can see the entirety of the code that occurs between the clock() calls.
clock()