c++/9344: in template, typedef for reference return type cannot be used
florian.kirsch@gmx.net
florian.kirsch@gmx.net
Thu Jan 16 21:16:00 GMT 2003
>Number: 9344
>Category: c++
>Synopsis: in template, typedef for reference return type cannot be used
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Thu Jan 16 13:16:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: Florian Kirsch
>Release: gcc version 3.4 20030115 (experimental)
>Organization:
>Environment:
Linux darkstar 2.4.14 #6 Tue Nov 6 17:10:23 MET 2001 i586 unknown
>Description:
The following code is stripped down from some meaningful code
(VRS, www.vrs3d.org). It compiles with gcc-3.0.4 and gcc-3.2.1.
With gcc head, I get the following error in function foo1():
kirsch@darkstar:/home/kirsch/gcctest > g++ container.cpp -o container.o
container.cpp:6: error: expected function-definition
#include <vector>
template<typename T> class Container {
public:
typedef typename std::vector<T>::reference ref;
Container<T>::ref foo1() { } // error
typename std::vector<T>::reference foo2() { } // ok
};
int main(int argc, char** argv) {
Container<int>* c = new Container<int>;
return 0;
}
Best regards,
Florian
>How-To-Repeat:
simply compile the above code
>Fix:
as a workaround, do not use a typedef for the return type,
as in function foo2().
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-prs
mailing list