I tried to compile the following C++11 code with mixed results.
struct NoTemplate {
static constexpr auto (*foo)() = false ? +[]{} : nullptr;
};
NoTemplate no_inst;
template<typename>
struct YesTemplate {
static constexpr auto (*foo)() = false ? +[]{} : nullptr;
};
YesTemplate<float> yes_inst;
- clang: Compiles
NoTemplate
sucessfully; giveserror: a lambda expression may not appear inside of a constant expression
onYesTemplate
. - gcc: Compiles both successfully
- msvc: Crashes.
- icc: Crashes (we have a winner!)
What is the correct result? I see some standard language suggesting non-constant expressions should be OK in the false branch of short-circuiting operators in constant expressions, but IANALL.