This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/79682] New: [concepts] ambiguous overload with functionally equivalent predicate constraints compiles


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

            Bug ID: 79682
           Summary: [concepts] ambiguous overload with functionally
                    equivalent predicate constraints compiles
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hstong at ca dot ibm.com
  Target Milestone: ---

Given the following source, the normalized constraints of the foo() returning
int contains predicate constraints:
N > 1
- and -
(N & 0x1) != 0

The normalized constraints of the foo() returning void contains:
(N & 0x1) != 0x0

The similar looking predicate constraints are not equivalent
([temp.over.link]).

The call in main() should therefore be ambiguous.

### Source (<stdin>):
template <unsigned N>
requires (N & 0x1) != 0 && (N > 1)
int foo() { return 0; }

template <unsigned N>
requires (N & 0x1) != 0x0
void foo() { }

int main(void) {
  return foo<0x03>();
}

### Compiler invocation:
g++ -std=c++1z -fconcepts -c -o /dev/null -x c++ -

### Actual output:
(Clean compile)

### Expected output:
<stdin>: In function 'int main()':
<stdin>:10:20: error: call of overloaded 'foo<3>()' is ambiguous
<stdin>:3:5: note: candidate: int foo() [with unsigned int N = 3]
<stdin>:7:6: note: candidate: void foo() [with unsigned int N = 3]

### Compiler version (g++ -v):
Using built-in specs.
COLLECT_GCC=/usr/local/gcc-head/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/7.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/heads/gcc/gcc-source/configure
--prefix=/usr/local/gcc-head --enable-languages=c,c++ --enable-lto
--disable-multilib --without-ppl --without-cloog-ppl --enable-checking=release
--disable-nls
Thread model: posix
gcc version 7.0.1 20170125 (experimental) (GCC)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]