public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109864] New: excplicit constructor considered during overload resolution leads to ambiguity
@ 2023-05-15 17:59 dmatthews at utexas dot edu
  2023-05-15 18:00 ` [Bug c++/109864] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dmatthews at utexas dot edu @ 2023-05-15 17:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109864
           Summary: excplicit constructor considered during overload
                    resolution leads to ambiguity
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dmatthews at utexas dot edu
  Target Milestone: ---

gcc version:
------------

Using built-in specs.
COLLECT_GCC=/opt/homebrew/opt/gcc/bin/gcc-13
COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/13.1.0/bin/../libexec/gcc/aarch64-apple-darwin21/13/lto-wrapper
Target: aarch64-apple-darwin21
Configured with: ../configure --prefix=/opt/homebrew/opt/gcc
--libdir=/opt/homebrew/opt/gcc/lib/gcc/current --disable-nls
--enable-checking=release --with-gcc-major-version-only
--enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-13
--with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr
--with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl
--with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 13.1.0'
--with-bugurl=https://github.com/Homebrew/homebrew-core/issues
--with-system-zlib --build=aarch64-apple-darwin21
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.1.0 (Homebrew GCC 13.1.0)

(also tested on all x86_64 versions back to 4.9.x on godbolt.org)

Steps to reproduce:
-------------------

1. Enter the following program in test.cxx:

#include <initializer_list>

struct foo
{
    foo(std::initializer_list<int>) {}
};

struct bar
{
    explicit bar(std::initializer_list<int>) {}
    bar() {}
    void baz(foo) {}
    void baz(bar&&) {}
};

int main()
{
    bar x;
    x.baz({1,2});
}

2. Compile with "gcc test.cxx".

Expected result:
----------------

The program should compile successfully, with a call to bar::baz(foo).

Actual result:
--------------

gcc reports an ambiguity between bar::baz(foo) and bar::baz(bar&&) even though
the latter involves the explicit constructor
bar::bar(std::initializer_list<int>) during an implicit conversion:

test.cxx: In function 'int main()':
test.cxx:19:10: error: call of overloaded 'baz(<brace-enclosed initializer
list>)' is ambiguous
   19 |     x.baz({1,2});
      |     ~~~~~^~~~~~~
test.cxx:12:10: note: candidate: 'void bar::baz(foo)'
   12 |     void baz(foo) {}
      |          ^~~
test.cxx:13:10: note: candidate: 'void bar::baz(bar&&)'
   13 |     void baz(bar&&) {}
      |          ^~~

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

* [Bug c++/109864] excplicit constructor considered during overload resolution leads to ambiguity
  2023-05-15 17:59 [Bug c++/109864] New: excplicit constructor considered during overload resolution leads to ambiguity dmatthews at utexas dot edu
@ 2023-05-15 18:00 ` pinskia at gcc dot gnu.org
  2023-05-15 18:08 ` arsen at gcc dot gnu.org
  2023-05-31 19:50 ` [Bug c++/109864] explicit " jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-15 18:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note there are some C++ defect reports in this area ....
And this is most likely a dup of another bug.

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

* [Bug c++/109864] excplicit constructor considered during overload resolution leads to ambiguity
  2023-05-15 17:59 [Bug c++/109864] New: excplicit constructor considered during overload resolution leads to ambiguity dmatthews at utexas dot edu
  2023-05-15 18:00 ` [Bug c++/109864] " pinskia at gcc dot gnu.org
@ 2023-05-15 18:08 ` arsen at gcc dot gnu.org
  2023-05-31 19:50 ` [Bug c++/109864] explicit " jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: arsen at gcc dot gnu.org @ 2023-05-15 18:08 UTC (permalink / raw)
  To: gcc-bugs

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

Arsen Arsenović <arsen at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arsen at gcc dot gnu.org

--- Comment #2 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
seems to be https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109247

a near exact match, even

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

* [Bug c++/109864] explicit constructor considered during overload resolution leads to ambiguity
  2023-05-15 17:59 [Bug c++/109864] New: excplicit constructor considered during overload resolution leads to ambiguity dmatthews at utexas dot edu
  2023-05-15 18:00 ` [Bug c++/109864] " pinskia at gcc dot gnu.org
  2023-05-15 18:08 ` arsen at gcc dot gnu.org
@ 2023-05-31 19:50 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2023-05-31 19:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Dup.

*** This bug has been marked as a duplicate of bug 60027 ***

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

end of thread, other threads:[~2023-05-31 19:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-15 17:59 [Bug c++/109864] New: excplicit constructor considered during overload resolution leads to ambiguity dmatthews at utexas dot edu
2023-05-15 18:00 ` [Bug c++/109864] " pinskia at gcc dot gnu.org
2023-05-15 18:08 ` arsen at gcc dot gnu.org
2023-05-31 19:50 ` [Bug c++/109864] explicit " jason 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).