public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107255] New: ation and definition of a template function which vary in use of concept auto syntax are interpreted as ambiguous overloadsdeclar
@ 2022-10-14  1:40 enolan at alumni dot cmu.edu
  2022-10-15  7:00 ` [Bug c++/107255] declaration and definition of a template function which vary in use of concept auto syntax are interpreted as ambiguous overloads de34 at live dot cn
  2022-10-15 13:33 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: enolan at alumni dot cmu.edu @ 2022-10-14  1:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107255
           Summary: ation and definition of a template function which vary
                    in use of concept auto syntax are interpreted as
                    ambiguous overloadsdeclar
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: enolan at alumni dot cmu.edu
  Target Milestone: ---

This is a rejects-valid bug where GCC has trouble determining that a
declaration and definition which vary only in their use of concept auto syntax
are for the same function and not multiple ambiguous overloads.

Compiler explorer link: https://godbolt.org/z/4Tjcz49d9

Minimal reproduction:

template <typename T>
concept Foo = true;

void bar(Foo auto);

template <Foo F>
void bar(F) {}

void baz() {
    bar(0);
}

> the exact version of GCC

gcc version 12.2.1 20220819 (Red Hat 12.2.1-2) (GCC)

> the system type

Fedora release 38 (Rawhide)

> the options given when GCC was configured/built

Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --enable-libstdcxx-backtrace
--with-linker-hash-style=gnu --enable-plugin --enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-12.2.1-20220819/obj-x86_64-redhat-linux/isl-install
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-offload-defaulted --enable-gnu-indirect-function --enable-cet
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
--with-build-config=bootstrap-lto --enable-link-serialization=1

> the complete command line that triggers the bug

g++ -std=c++20 poc.cpp

> the compiler output

poc.cpp: In function ‘void baz()’:
poc.cpp:10:8: error: call of overloaded ‘bar(int)’ is ambiguous
   10 |     bar(0);
      |     ~~~^~~
poc.cpp:4:6: note: candidate: ‘void bar(auto:1) [with auto:1 = int]’
    4 | void bar(Foo auto);
      |      ^~~
poc.cpp:7:6: note: candidate: ‘void bar(F) [with F = int]’
    7 | void bar(F) {}
      |      ^~~

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/107255] declaration and definition of a template function which vary in use of concept auto syntax are interpreted as ambiguous overloads
  2022-10-14  1:40 [Bug c++/107255] New: ation and definition of a template function which vary in use of concept auto syntax are interpreted as ambiguous overloadsdeclar enolan at alumni dot cmu.edu
@ 2022-10-15  7:00 ` de34 at live dot cn
  2022-10-15 13:33 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: de34 at live dot cn @ 2022-10-15  7:00 UTC (permalink / raw)
  To: gcc-bugs

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

Jiang An <de34 at live dot cn> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |de34 at live dot cn

--- Comment #1 from Jiang An <de34 at live dot cn> ---
I think two declarations are functionally-equivalent but not equivalent. So the
program is ill-formed, no diagnostic required. IIUC gcc is just doing the right
thing (at least something nice to have) here.

The current normative wording in [dcl.fct] seems defective. See also following
editorial issues.

https://github.com/cplusplus/draft/issues/5495
https://github.com/cplusplus/draft/issues/4121

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/107255] declaration and definition of a template function which vary in use of concept auto syntax are interpreted as ambiguous overloads
  2022-10-14  1:40 [Bug c++/107255] New: ation and definition of a template function which vary in use of concept auto syntax are interpreted as ambiguous overloadsdeclar enolan at alumni dot cmu.edu
  2022-10-15  7:00 ` [Bug c++/107255] declaration and definition of a template function which vary in use of concept auto syntax are interpreted as ambiguous overloads de34 at live dot cn
@ 2022-10-15 13:33 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-15 13:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jiang An from comment #1)
> I think two declarations are functionally-equivalent but not equivalent.

Yes, I think you're right. Similarly, these are not equivalent despite looking
superficially the same:

template <class F> requires Foo<F>
void bar(F) {}

template <class F>
void bar(F) requires Foo<F> {}

(Lookup for "Foo" actually considers different scopes in these two cases.)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-15 13:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-14  1:40 [Bug c++/107255] New: ation and definition of a template function which vary in use of concept auto syntax are interpreted as ambiguous overloadsdeclar enolan at alumni dot cmu.edu
2022-10-15  7:00 ` [Bug c++/107255] declaration and definition of a template function which vary in use of concept auto syntax are interpreted as ambiguous overloads de34 at live dot cn
2022-10-15 13:33 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).