https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81547
Bug ID: 81547 Summary: Surrogate call function results in call to other conversion operator Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: accepts-invalid, rejects-valid, wrong-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hstong at ca dot ibm.com Target Milestone: --- In the C++17 DIS subclause 16.3.1.1.2 [over.call.object] paragraph 3, it is stated that the conversion function corresponding to the selected surrogate call function is used to determine the function which is to be called by the call syntax. It appears that GCC instead chooses the function selected for the user-defined conversion sequence formed for overload resolution. ### SOURCE (<stdin>): using ff = int (*)(int); constexpr int ffimpl0(int x) { return x; } constexpr int ffimpl1(int x) { return x + 1; } struct A { template <typename T> constexpr operator T() const { return ffimpl0; } constexpr operator ff() const volatile { return ffimpl1; } }; char x[A()(42.f)]; extern char x[43]; // Clang accepts; GCC rejects ### COMPILER INVOCATION: g++ -fsyntax-only -std=c++11 -x c++ - ### ACTUAL OUTPUT: <stdin>:11:17: error: conflicting declaration 'char x [43]' <stdin>:10:6: note: previous declaration as 'char x [42]' ### EXPECTED OUTPUT: (clean compile) ### COMPILER VERSION INFO (g++ -v): Using built-in specs. COLLECT_GCC=/opt/wandbox/gcc-head/bin/g++ COLLECT_LTO_WRAPPER=/opt/wandbox/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../source/configure --prefix=/opt/wandbox/gcc-head --enable-languages=c,c++ --disable-multilib --without-ppl --without-cloog-ppl --enable-checking=release --disable-nls --enable-lto LDFLAGS=-Wl,-rpath,/opt/wandbox/gcc-head/lib,-rpath,/opt/wandbox/gcc-head/lib64,-rpath,/opt/wandbox/gcc-head/lib32 Thread model: posix gcc version 8.0.0 20170724 (experimental) (GCC)