public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "dmatthews at utexas dot edu" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109864] New: excplicit constructor considered during overload resolution leads to ambiguity Date: Mon, 15 May 2023 17:59:58 +0000 [thread overview] Message-ID: <bug-109864-4@http.gcc.gnu.org/bugzilla/> (raw) 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&&) {} | ^~~
next reply other threads:[~2023-05-15 17:59 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-15 17:59 dmatthews at utexas dot edu [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-109864-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).