Returning reference to a local variable

前端 未结 7 1245
忘掉有多难
忘掉有多难 2020-12-18 14:04

Why can this code run successfully in Code::block. The IDB just reports

warning: \"reference to local variable ‘tmp’ returned\",

7条回答
  •  半阙折子戏
    2020-12-18 14:26

    You are causing an undefined behaviour. The standard doesn't tell what happens in that case, however your compiler detected it.

提交回复
热议问题