https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95626
Bug ID: 95626
Summary: [concepts] incorrect ambiguous overload with
constraints "A && !B" vs "!B"
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: godeffroy.valet at m4x dot org
Target Milestone: ---
Created attachment 48715
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48715&action=edit
preprocessed source code
The following code fails to compile, giving an "ambiguous overload" error while
one function is clrearly more constrined than the other.
#include
template concept ConceptA=std::is_same::value;
template concept ConceptB=std::is_same::value;
template
requires (!ConceptB && ConceptA)
auto constexpr test__(A const& ){
}
template
requires (!ConceptB)
auto constexpr test__(A const& ){
}
int main(){
test__(2); // error
}
Note that the negation in "!ConceptB" is required to reproduced the issue.
In particular, the following code compiles.
#include
template concept ConceptA=std::is_same::value;
template concept ConceptB=!std::is_same::value;
template
requires (ConceptB && ConceptA)
auto constexpr test__(A const& ){
}
template
requires (ConceptB)
auto constexpr test__(A const& ){
}
int main(){
test__(2); // OK
}
Command used : g++ -std=c++2a -Wall -Wextra test.cpp
Output :
geometry/algebra/definition.test.cpp: In function 'int main()':
geometry/algebra/definition.test.cpp:23:10: error: call of overloaded
'test__(int)' is ambiguous
23 | test__(2);
| ^
geometry/algebra/definition.test.cpp:10:17: note: candidate: 'constexpr auto
test__(const A&) [with A = int]'
10 | auto constexpr test__(A const& ){
| ^~
geometry/algebra/definition.test.cpp:14:17: note: candidate: 'constexpr auto
test__(const A&) [with A = int]'
14 | auto constexpr test__(A const& ){
| ^~
Output of gcc -v :
Utilisation des specs internes.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/lto-wrapper
Cible : x86_64-pc-linux-gnu
Configuré avec: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/usr/include/dlang/gdc
Modèle de thread: posix
Algorithmes de compression LTO supportés: zlib zstd
gcc version 10.1.0 (GCC)