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++/81486] New: Class template argument deduction fails with (), succeeds with {}


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

            Bug ID: 81486
           Summary: Class template argument deduction fails with (),
                    succeeds with {}
           Product: gcc
           Version: 7.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Consider this example, simplified from
https://stackoverflow.com/q/45195890/2069064:

template <class T>
struct C { 
    C(T );
};

template <>
struct C<void> { };

C() -> C<void>;

int main() {
    auto a = C{}; // ok
    auto b = C(); // error
}

The two forms are equivalent in this context - a and b should both deduce to
C<void>. Yet, gcc accepts a and errors on b with: cannot deduce template
arguments for 'C' from ()

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