main() { char c1,c2,c3; c1 = 10; c2 = 5; c3 = c1 * c2; }
When I try to debug it in Debugger, I find code is not generated for char data types. However if define it as int then the code is generated.
Thanks in advance for your help.
"nobody claimed that we do!"
I was wondering about that too. I haven't seen anyone trying an explanation of what differences in the compiler optimizer that got trigged differently for char or int variables.
I explicitly wrote "If we ignore the situation that it makes a difference if you use char or int as type, [...]" in my original post just because it wouldn't be meaningful to try to speculate about it.
The debate in the thread is about dead-code elimination. A common trait of most compilers, and definitely a part of all good C/C++ compilers. Just as it is up to the compiler [developers] to decide the meaning of the different optimization flags, and when a specific dead-code elimination will happen.
But we don't need to have the source code to a compiler to recognize dead-code elimination in action, and be able to tell what is making the code into "dead code" and how it can be modified to create a forced side effect where the C standard will demand that the compiler do output some actions for the processor to perform. Of course, the use of 'volatile' will not be enough, if the compiler and/or linker can figure out that the function may never be called.