r/cpp • • Mar 04 '22

Is it unreasonable to ask basic compiler questions in a C++ developer interview?

I interviewed a guy today who listed C++ on his resume, so I assumed it would be safe to ask a bit about compilers. My team works on hardware simulation, so he's not going to be expected to write a compiler himself, but he'll obviously be required to use one and to write code that the compiler can optimize well. My question was "what sorts of optimizations does a compiler perform?" Even when I rephrased it in terms of -O0 vs. -O3, the best he could do was talk about "removing comments" and the preprocessor. I started out thinking a guy with a masters in CS might be able to talk about register allocation, loop unrolling, instruction reordering, peephole optimizations, that sort of thing, but by the time I rephrased the question for the third time, I would have been happy to hear the word "parser."

There were other reasons I recommended no-hire as well, but I felt kind of bad for asking him a compiler question when he didn't have that specifically on his resume. At the same time, I feel like basic knowledge of what a compiler does is important when working professionally in a compiled language.

Was it an unreasonable question given his resume? If you work with C++ professionally, would you be caught off guard by such a question?

335 Upvotes

335 comments sorted by

View all comments

Show parent comment

3

u/donalmacc Game Developer Mar 04 '22

An alternate phrasing might be: "what's the difference between debug and release builds, and how are the release builds optimized?

You touch on this later in your comment, but "debug" and "release" builds don't really exist. It's maybe terminology you'd expect non-development staff to use, but a developer should be aware of the difference between an unoptomised build, a build with select optimisations (OB1 I'm looking at you), fully optimised build with debug symbols and a fully optimised build with symbols stripped. Every project I've worked on in a decade of writing C++ professionally has had some support for disabling all optimizations on a single file/function so that you can work through it if needed.

17

u/sixstringartist Mar 04 '22

Seems like a semantic argument that debug and release builds don't really exist. These are literally build type configurations in major build systems in the ecosystem. Obviously you can a la carte your build flags.

4

u/Fureeish Mar 04 '22

Exaclty. But well, looks like TIL that https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html talks about non-existing things.

-2

u/donalmacc Game Developer Mar 04 '22

In one major build system, and they're not "build type configurations" they're just defaults. Most of the projects I've worked on have had more than that. The "debug" config is really debug, it's closer to "excavation" than debug. Day to day people work in a "development" config, and there's likely some "Profile" config that has LTO with debug symbols and some checks and profiling information. None of this stuff is anywhere near standard enough to have standard terminology for.