This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/32408] Template Parsing Error
- From: "chsalvia at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Jun 2007 23:08:01 -0000
- Subject: [Bug c++/32408] Template Parsing Error
- References: <bug-32408-14723@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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