Re: please review: possible C++ template bug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Code sample below. I believe this is a gcc compiler bug because line
16 gives an error "has not been declared" when the function call in
question is clearly dependent on the template parameter and therefore
logically shouldn't be declared until template instantiation.

Section 14.6.2 of the Standard and section C.13.8.1 of Stroustrup seem
to agree with me, for example from the latter: "Basically, the name of
a function called is dependent if it is obviously dependent by looking
at its arguments or at its formal parameters."

Thanks,
=Shawn Yarbrough


// hello.cpp
#include <vector>

class CC {
public:
    void bar();
    void bar(int *);
    void bar(float *);

    template<typename TT> static void foo(std::vector<TT*> &vec);
};

template<typename TT>
void CC::foo(std::vector<TT*> &vec) {
    TT *tt;
    ::bar(tt);    // error: '::bar' has not been declared
    vec.push_back(tt);
}

class Argh {};
void bar(Argh *&aa) { aa = new Argh; }

class Blah {};
void bar(Blah *&bb) { bb = new Blah; }

int main(int argc, char *argv[]) {
    std::vector<Blah*> vec;
    CC::foo(vec);
    return 0;
}


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux