[Bug c++/41231] New: Error when declaring a nested template member class of a dependent template class a friend

2009-09-02 Thread pleexed at gmail dot com
Hello,

this is my first bug report, so please don't be harsh with me in case i did
something wrong.

I'm on Ubuntu Jaunty i386, with all the packages installed from and updated to
the most recent version of the official repositories. I'm trying to build for
that system too (no cross-compiling).

This is the g++ version I have:
$ g++ --version
g++ (Ubuntu 4.3.2-2ubuntu9) 4.3.3 20081217 (prerelease)
$ g++ -dumpmachine
i486-linux-gnu

And this how I invoke g++:
$ g++ -Wall test.cpp
test.cpp:11: error: expected identifier before ';' token
test.cpp:11: error: friend declaration does not name a class or function

I have distilled the testcase to just a few lines, and saved them to test.cpp.
I'll paste the contents here:
template class Outer
{
public:
template class Inner
{
};
};

template class Friend
{
friend class Outer::template Inner; //line 11
};

I don't see why this code should not compile, and the "tryitout" version of
Comeau compiles this in strict mode, and so does Visual C++ 2008.
Unfortunately, I cannot install any other version of g++ right now, but I have
asked someone with gcc 4.4.x on freenode ##C++ to try to compile that code
snippet, and he had the same result as I had. geordi is a bot in that channel
to which you can send small samples of code to compile, and it says it runs
"g++ (GCC) 4.5.0 20090803 (experimental)". geordi cannot compile that code
either.

Can you please give me some insight into why this code fails to compile with
g++? In any case, be it g++ that is wrong or right in refusing to compile, is
there a workaround I can use to achieve what I need?

I'm happy to assist you should you need further tests or data.


-- 
   Summary: Error when declaring a nested template member class of a
dependent template class a friend
   Product: gcc
   Version: 4.3.3
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pleexed at gmail dot com


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



[Bug c++/41231] Error when declaring a nested template member class of a dependent template class a friend

2009-09-03 Thread pleexed at gmail dot com


--- Comment #2 from pleexed at gmail dot com  2009-09-03 16:36 ---
Created an attachment (id=18481)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18481&action=view)
Workaround

By declaring a typedef in a templated proxy class and using that in the friend
declaration, the desired effect of the original testcase can be produced,
without provoking a compiler or linker error.

The code in this attachment works on my system as posted in the initial bug
report (g++ (Ubuntu 4.3.2-2ubuntu9) 4.3.3 20081217 (prerelease)).


-- 


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