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++/62206] New: Gcc doesn't optimize methods in template class, even when they don't depend on the template variable


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

            Bug ID: 62206
           Summary: Gcc doesn't optimize methods in template class, even
                    when they don't depend on the template variable
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tohava at gmail dot com

Take a look at the following code:

    #include <stdio.h>

    template <class T>
    class C {
    public:
        static int foobar() { printf("helloworld\n"); }
    };

    int main() {
        C<int>::foobar();
        C<double>::foobar();
    }

Since olga_rocks is not dependent on the template parameter T, I would expect
gcc to generate only a single version of `olga_rocks`. However, it generates
two identical versions instead, even when compiling with `-O3 -fno-inline`.


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