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++/29427] New: uncallable constructor template should be warned.


class foo {
public:
    template<typename T>
        foo(int i) : j(i) {}
    template<typename T>
    void bar(int i) { j = i; }
    template<typename T>
    static
    void baz(int i) {}
    int j;
    };
int main() {
    foo::baz<bool>(3);
    foo* p; p->bar<bool>(3);
    new foo<bool>(3);
    return 0;
    }


gets you:
~/ootbc/chips$ g++ foo.cc
foo.cc: In function âint main()â:
foo.cc:8: error: âfooâ is not a template
foo.cc:8: error: no matching function for call to âfoo::foo(int)â
foo.cc:1: note: candidates are: foo::foo(const foo&)


The problem is that the constructor was declared as a template, hence cannot be
called (see bug# 29008). This can be detected at the declaration and a warning
should issue.
OK.


-- 
           Summary: uncallable constructor template should be warned.
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29427


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