[Bug c++/79381] New: [concepts] Call to template function with type-requirement unsatisfied not rejected
d25fe0be at yandex dot com
gcc-bugzilla@gcc.gnu.org
Sun Feb 5 13:31:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79381
Bug ID: 79381
Summary: [concepts] Call to template function with
type-requirement unsatisfied not rejected
Product: gcc
Version: 7.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: d25fe0be at yandex dot com
Target Milestone: ---
$ cat t.cpp
template <class T> struct DeriveFrom : T {};
template <class T> concept bool Derivable = requires { typename DeriveFrom<T>;
};
void foo() {};
void TryDerivable(Derivable) {}
int main() {
TryDerivable(foo);
}
$ g++-7 ./t.cpp -fconcepts -Wall -Wextra
$
As stated in n4377/5.1.4.2 (expr.prim.req.type):
[quote] A type requirement asserts the validity of ... a class template
specialization ... [/quote]
Specializing 'DeriveFrom' with 'decltype(foo)' results in deriving from some
function pointer type, which is ill-formed. So 'foo' does not satisfy the
'Derivable' constraint. And the compilation should fail.
$ g++-7 -v
Using built-in specs.
COLLECT_GCC=g++-7
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/HEAD-245030_1/libexec/gcc/x86_64-apple-darwin16.3.0/7.0.1/lto-wrapper
Target: x86_64-apple-darwin16.3.0
Configured with: ../configure --build=x86_64-apple-darwin16.3.0
--prefix=/usr/local/Cellar/gcc/HEAD-245030_1
--libdir=/usr/local/Cellar/gcc/HEAD-245030_1/lib/gcc/7
--enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-7
--with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr
--with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl
--with-system-zlib --enable-stage1-checking --enable-checking=release
--enable-lto --with-build-config=bootstrap-debug --disable-werror
--with-pkgversion='Homebrew GCC HEAD-245030_1'
--with-bugurl=https://github.com/Homebrew/homebrew-core/issues
--enable-multilib
Thread model: posix
gcc version 7.0.1 20170130 (experimental) (Homebrew GCC HEAD-245030_1s)
More information about the Gcc-bugs
mailing list