Copying duplicates is usually bad and often quite easy to spot. I believe that compilers could automatically detect this in the simplest cases β they already parse the text and get an intermediate representation, which they parse differently β they detect suspicious patterns such as uninitialized variables, optimize the emitted code, etc. I assume that they could often detect functionally duplicate code in the same way and consider it when issuing machine code.
Are there C ++ compilers that can detect duplicate code and only select the corresponding machine code once instead of each duplicate in the source code?
c ++ compiler-construction
sharptooth
source share