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++/84306] New: Wrong overload selected with -std=c++17, explicit and {}


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

            Bug ID: 84306
           Summary: Wrong overload selected with -std=c++17, explicit and
                    {}
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antoshkka at gmail dot com
  Target Milestone: ---

Following code uses function (1), however function (2) must be used.

struct foo {
    foo() = default;

    foo(foo const&);   // (1)

    template<typename T>
    explicit foo(T&&); // (2)
};

int main() {
    foo f1;
    foo f2{f1};  // (1) - wrong, must be (2)
}


The compiler chooses the right function if 'explicit' is removed, or if '{f1}'
is replaced with '(f1)', or if -std=c++17 option is changed to -std=c++14.

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