Your message dated Sat, 8 Jul 2006 21:30:41 +0200
with message-id <[EMAIL PROTECTED]>
and subject line [Bug c++/28317] template function returning nested class fails
to compile when defined outside of its class (forwarded from rguenth at gcc dot
gnu dot org)
has caused the attached Bug report to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere. Please contact me immediately.)
Debian bug tracking system administrator
(administrator, Debian Bugs database)
--- Begin Message ---
Package: g++-4.0
Version: 4.0.3-3
Severity: normal
Dear maintainer,
The following code generates the g++ compiler error:
14: error: expected constructor, destructor, or type conversion
before Outer
template <typename T>
class Outer
{
public:
class Inner
{
};
Inner get() const;
};
template <typename T>
Outer<T>::Inner
Outer<T>::get() const // <-- this is line 14
{
return Inner();
}
If the function get() is placed inside the template class Outer, no error is
reported. E.g.,
template <typename T>
class Outer
{
public:
class Inner
{
};
Inner get() const
{
return Inner();
}
};
An external definition compiles well if the class Inner is explicitly defined
as a template class (even though no template parameters are required). E.g.,
template <typename T>
class Outer
{
public:
template <typename U>
class Inner
{
};
Inner<T> get() const;
};
template <typename T>
Outer<T>::Inner<T>
Outer<T>::get() const
{
return Inner<T>();
}
Moreover, the first source, producing a compilation error with g++ was also
offered to the intel C++ compiler, where it compiled flawlessly. Here is a
transcript of the issued commands, illustrating the difference:
[EMAIL PROTECTED]:~/programming/C++$ g++ -c -Wall demo1.cxx
demo1.cxx:14: error: expected constructor, destructor, or type
conversion before ?Outer?
[EMAIL PROTECTED]:~/programming/C++$ icc -c -Wall demo1.cxx
[EMAIL PROTECTED]:~/programming/C++$
My considerations for filing a bug report were:
* g++ produces a compilation error where icc doesn't;
* g++'s compilation error is only produced when the template function is
defined outside of its template class;
* the reported error message is rather cryptic, given the nature of the
source, suggesting confusion on the part of the compiler.
Of course, g++ might offer a more rigid implementation of the C++ standard at
this point. However, I couldn't find a clear indication that the external
function implementation violates the standard. Hence the bug report.
-- System Information:
Debian Release: testing/unstable
APT prefers testing
APT policy: (500, 'testing')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Versions of packages g++-4.0 depends on:
ii gcc-4.0 4.0.3-3 The GNU C compiler
ii gcc-4.0-base 4.0.3-3 The GNU Compiler Collection (base
ii libc6 2.3.6-13 GNU C Library: Shared libraries
ii libstdc++6-4.0-dev 4.0.3-3 The GNU Standard C++ Library v3 (d
g++-4.0 recommends no packages.
-- no debconf information
--- End Message ---
--- Begin Message ---
--- Begin Message ---
------- Comment #1 from rguenth at gcc dot gnu dot org 2006-07-08 18:20 -------
You are missing a 'typename'. Inner is a dependent type, so it needs to read
template <typename T>
typename Outer<T>::Inner
Outer<T>::get() const
{
return Inner();
}
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28317
------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
--- End Message ---
--- End Message ---