https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827

--- Comment #3 from Matthias Kretz <kretz at kde dot org> ---
But macros are different. They remove the code before the C++ parser sees it
(at least as-if). One great improvement of constexpr-if over macros is that all
the other branches are parsed and their syntax checked. E.g. it requires the
mentioned names to exist. This doesn't compile (cf.
https://godbolt.org/g/iCRPDv):

#ifdef HAVE_FOO
constexpr bool have_foo = true;
void foo();
#else
constexpr bool have_foo = false;
#endif

void f() {
  if constexpr (have_foo) {
    foo();
  }
}

So, the frontend parses all branches anyway. It should be able to see that _2
and _3 are referenced in f<1>().

Reply via email to