CSR Interview Question
Country: United States
is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
First of all CSR asks always stupid questions and this question is not any different.I hope they stop asking stupid questions which they themselves are not clear about.
volatile means the value of that variable is always read from its memory location on access and written to its memory location on mutation.So any optimization(by the compiler) that doesn't affect this can still be used.
Compiler uses all the tricks to make your code faster such as 'tail call'.
Most of the time the compiler would read the memory to get the value but in below code it may not do that as it can find out(probably by static analysis) that this value is not going to change so it will optimize it.
Compiler will optimise it as below:
So by adding volatile you are just instructing the compiler to not do this and compiler.
- aka January 30, 2013How does it do that would be specific to compiler.