Does “Return Value Optimization” cause undefined behavior?

Reading this Wikipedia article pointed out to one of the respondents the following question:

C ++ Copy constructor, time frame and copy semantics

I came across this line

Depending on the compiler and compiler settings, the resulting program may display any of the following outputs:

Is this not suitable for undefined behavior? I know the article says Depending on the compiler and settings, but I just want to clear it.

+5
source share
4 answers

, undefined. undefined ( : ", , , ".) , undefined.

, - undefined undefined (.. - ). : , .

+12

. . Undefined , .

:

+2
+1

, undefined. , - , . , , - " , , ", undefined.

, . , - , , .

, - .. , , - . "Hello World!" , , .

0

All Articles