Considering
C++11 §1.10/24 (in [intro.multithread])
” The implementation may assume that any thread will eventually do one of the following:
— terminate,
— make a call to a library I/O function,
— access or modify a volatile object, or
— perform a synchronization operation or an atomic operation.
[Note: This is intended to allow compiler transformations such as removal of empty loops, even when termination cannot be proven. —end note ]
… is the compiler allowed to optimize away the following loop:
int main(int argc, char* argv[]) {
while ( true )
fork();
}
?
(There is some earlier discussion at (Optimizing away a "while(1);" in C++0x), but it does not seem to answer the case of a fork
call in the loop.)
Aucun commentaire:
Enregistrer un commentaire