KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have always been told that compiler is sufficient smart to eliminate dead code. Much of the code that I am writing has a lot of information known at compile time but the code has to be written in most generic form. I don't know any assembly so I cannot examine the generated assembly. What kind of code that can be effectively eliminated in the final executable? Few examples but not limited to f(bool b){ if(b){ //some code }else{ //some code } } f(true); ////////////////////////// template<bool b> f(){ if(b){ //some code }else{ //some code } } f<true>(); /////////////////////////// What if definition of f is in other objective code and the the called f(true) is in main. Will link time optimisation effectively eliminate the dead code? What is the coding style/compiler option/trick to facilitate dead code elimination?
Tags (comma-separated)
Save Edits
Cancel