C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Please help to judge if it's a bug of g++!

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Kevin Wan
Guest





PostPosted: Fri Feb 27, 2004 2:57 am    Post subject: Please help to judge if it's a bug of g++! Reply with quote



I have such a program!

template <typename T>
struct A
{
template <bool b>
void aaa() {}
};

template <typename T>
struct B
{
A<int> a;
void bbb() { a.aaa<true>(); }
};

int main()
{
B<int> b;
b.bbb();
}

$ g++ test.cc
template.cc: In member function `void B<T>::bbb()':
template.cc:12: syntax error before `;' token
$ g++ --version
g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-20)


Please help to confirm if it's a bug of g++!
Thanks a lot!
jfwan
Back to top
Alf P. Steinbach
Guest





PostPosted: Fri Feb 27, 2004 3:16 am    Post subject: Re: Please help to judge if it's a bug of g++! Reply with quote



* [email]jfwan (AT) vip (DOT) sina.com[/email] (Kevin Wan) schriebt:
Quote:

template <typename T
struct A
{
template void aaa() {}
};

template struct B
{
A void bbb() { a.aaa<true>(); }
};

int main()
{
B<int> b;
b.bbb();
}

$ g++ test.cc
template.cc: In member function `void B<T>::bbb()':
template.cc:12: syntax error before `;' token
$ g++ --version
g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-20)


$ g++ --version | grep GCC
g++ (GCC) 3.3
$ g++ -pedantic -ansi main.cpp
main.cpp:11: error: parse error before `;' token
main.cpp: In member function `void B<T>::bbb()':
main.cpp:12: error: parse error before `;' token
$ _

However, Microsoft Visual C++ 7.1 and Comeau Online,
<url: http://www.comeaucomputing.com/tryitout/>,
compile the same code OK, no errors.


Back to top
Jonathan Turkanis
Guest





PostPosted: Fri Feb 27, 2004 3:18 am    Post subject: Re: Please help to judge if it's a bug of g++! Reply with quote



"Kevin Wan" <jfwan (AT) vip (DOT) sina.com> wrote

Quote:
I have such a program!

template <typename T
struct A
{
template void aaa() {}
};

template struct B
{
A void bbb() { a.aaa<true>(); }
};

int main()
{
B<int> b;
b.bbb();
}

It's a bug. Here's a hackish workaround -- only useful if aaa isn't
part of the public interface.

Jonathan

-----------------

template<bool b> struct dummy { };

template <typename T>
struct A
{
template <bool b>
void aaa(dummy<b>) {}
};

template <typename T>
struct B
{
A<int> a;
void bbb() { a.aaa(dummy<true>()); }
};

int main()
{
B<int> b;
b.bbb();
}



Back to top
Ron Natalie
Guest





PostPosted: Fri Feb 27, 2004 5:39 pm    Post subject: Re: Please help to judge if it's a bug of g++! Reply with quote


"Kevin Wan" <jfwan (AT) vip (DOT) sina.com> wrote

Quote:
I have such a program!

template <typename T
struct A

void bbb() { a.aaa

true is not a type name.
a.aaa<bool>();

or change A::aaa to take a bool template arg. It's not clear from the code snippet you
provided what you intend to do.


Back to top
Jonathan Turkanis
Guest





PostPosted: Fri Feb 27, 2004 5:46 pm    Post subject: Re: Please help to judge if it's a bug of g++! Reply with quote


"Ron Natalie" <ron (AT) sensor (DOT) com> wrote

Quote:

"Kevin Wan" <jfwan (AT) vip (DOT) sina.com> wrote

I have such a program!

template <typename T
struct A

void bbb() { a.aaa
true is not a type name.
a.aaa<bool>();

or change A::aaa to take a bool template arg. It's not clear from
the code snippet you
provided what you intend to do.


I think the OP's example is correct. true is a template argument for
the member template aaa of A, which has a bool parameter, not a
typename parameter.

Jonathan



Back to top
Rob Williscroft
Guest





PostPosted: Fri Feb 27, 2004 5:59 pm    Post subject: Re: Please help to judge if it's a bug of g++! Reply with quote

Kevin Wan wrote in news:5cea9465.0402261857.7930148f (AT) posting (DOT) google.com:

Quote:
I have such a program!

template <typename T
struct A
{
template void aaa() {}
};

template struct B
{
A void bbb() { a.aaa<true>(); }

This should compile, but there is a bug in gcc, replace with:

void bbb() { a.template aaa<true>(); }

Quote:
};

int main()
{
B<int> b;
b.bbb();
}

[snip]


Please help to confirm if it's a bug of g++!

Yep, but it isn't in the upcoming 3.4 release.

PS. I tried the above code on 4 compilers and non of them complained
about the unnesassery .template

Rob.
--
http://www.victim-prime.dsl.pipex.com/

Back to top
Ron Natalie
Guest





PostPosted: Fri Feb 27, 2004 6:07 pm    Post subject: Re: Please help to judge if it's a bug of g++! Reply with quote


"Jonathan Turkanis" <technews (AT) kangaroologic (DOT) com> wrote


Quote:

I think the OP's example is correct. true is a template argument for
the member template aaa of A, which has a bool parameter, not a
typename parameter.

Oops, so it does. Sorry about that.


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.