https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82047
Bug ID: 82047
Summary: non-existent variable template used to initialize
variable
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: john at mcfarlane dot name
Target Milestone: ---
The following code compiles:
template<typename T> struct S {};
template<typename T> constexpr T v;
constexpr auto c = v<S<void>>;
The result is a variable of type `struct S<void>` which appears to be
value-initialized.
Expected:
Compiler emits an error for `c` because there is no such variable as `v` of `S`
of `void` (or `v` of anything else for that matter).
Command:
g++ file.cpp -std=c++17
Version:
Observed in 7.1, 7.2 and 8.0 on Wandbox and in 7.1 on Ubuntu 16.04:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/local/ANT/johmcfj/gcc/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/local/ANT/johmcfj/Downloads/gcc-7.1.0/./configure
--disable-multilib --prefix=/home/local/ANT/johmcfj/gcc/
--enable-languages=c,c++,lto
Thread model: posix
gcc version 7.1.0 (GCC)