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++/32408] Template Parsing Error



------- Comment #3 from chsalvia at gmail dot com  2007-06-19 23:08 -------
Sorry.  It seems this is actually a namespace conflict issue.  If you add
include the iostream header file and add "using namespace std" the code will
not compile, due to a conflict with std::count.

#include <iostream>
using namespace std;

template <class T>
struct templated_struct 
{
        int count;
};

template <class T>
int template_func()
{
        templated_struct<T> s;
        if (s.count < 0) return 0;
        return 0;
}

int main()
{
        template_func<int> ();
        return 0;
}

Now I'm not completely sure if this should be considered a bug.  However, since
count is clearly a member of templated_struct, there shouldn't be a namespace
conflict here.  Also, if you replace '<' with '>' or '==', it compiles fine
with no namespace conflict, which means gcc seems to be confusing '<' with a
template argument.


-- 


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


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