[Bug c++/94038] New: Compiling with -Wall causes function template to get needlessly instantiated
ppalka at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Mar 4 20:26:00 GMT 2020
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.
More information about the Gcc-bugs
mailing list