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

            Bug ID: 94038
           Summary: Compiling with -Wall causes function template to get
                    needlessly instantiated
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppalka at gcc dot gnu.org
  Target Milestone: ---

With GCC trunk:

$ cat sa.cc
template<typename T>
constexpr int
foo()
{
  static_assert(T(1) == 0);
  return 0;
}

constexpr int
bar(int a)
{
  return a;
}

static_assert(decltype(bar(foo<int>())){} == 0);
$ g++ -fsyntax-only -O sa.cc
$ g++ -fsyntax-only -O -Wall sa.cc
sa.cc: In instantiation of ‘constexpr int foo() [with T = int]’:
sa.cc:15:36:   required from here
sa.cc:5:22: error: static assertion failed
    5 |   static_assert(T(1) == 0);
      |                 ~~~~~^~~~


This seems to be a regression from GCC 9.

Reply via email to