Talk:Useless instructions

From Rosetta Code
Revision as of 14:42, 16 October 2021 by PureFox (talk | contribs) (→‎if true {} else { code that is never executed }: Response to Tigerofdarkness.)

Leaving this as a draft for now since I'm not sure if this applies to anything that isn't assembly. --Puppydrum64 (talk) 04:01, 16 October 2021 (UTC)

if true {} else { code that is never executed }

Constructs like the above (suitably formatted for the language in question) could be useful to "temporarily" stop the execution of the else part during development. Although the compiler doesn't complain (though issuing an "unreachable code" warning would presumably be not that hard) do we know whether it actually generates code for the else part? --Tigerofdarkness (talk) 11:02, 16 October 2021 (UTC)

Of the 3 languages I've added, Go and C (using GCC) optimize away the else part.
However, the Wren compiler which is single pass does no optimizations and consequently does produce bytecode for the else part which is then interpreted by the VM. --PureFox (talk) 14:42, 16 October 2021 (UTC)