public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/46839] New: Parser confuses derived member with std::forward
@ 2010-12-07 17:02 foehst at informatik dot uni-kl.de
2010-12-07 17:12 ` [Bug c++/46839] " foehst at informatik dot uni-kl.de
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: foehst at informatik dot uni-kl.de @ 2010-12-07 17:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46839
Summary: Parser confuses derived member with std::forward
Product: gcc
Version: 4.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: foehst@informatik.uni-kl.de
Created attachment 22673
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22673
Info about gcc build configuration
01: #include <iostream>
02: #include <utility>
03: using namespace std;
04:
05: template <typename T> struct A
06: {
07: T forward;
08: A() : forward(0) {}
09: };
10:
11: template <typename T> struct B : public A<T>
12: {
13: void Function()
14: {
15: cout << (this->forward > 1) << endl;
16: cout << (this->forward < 1) << endl;
17: }
18: };
19:
20: int main(int argc, char **argv)
21: {
22: return 0;
23: }
g++ -Wall -std=gnu++0x
: In member function ‘void B<T>::Function()’:
:16: error: parse error in template argument list
Used compiler version: gcc version 4.4.3 (Gentoo 4.4.3-r2 p1.2)
4.3 and 4.5 versions show the same behavior.
It seems, that in line 16 "forward <" is parsed as the beginning of a template
instantiation. To get this effect, the inclusion of <utility>, using namespace
std and using derived members in a template class is necessary. Maybe, using
namespace typically appears after template definition in other h-files, but a
scenario like this might occur. Apart from that: Would
"this->std::forward<...>" be valid C++ code?
Therefore, I think that is a bug in the parsers which neglects the occurrence
of this and starts to interpret forward as the std::forward template.
Regards,
Tobias Föhst
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/46839] Parser confuses derived member with std::forward
2010-12-07 17:02 [Bug c++/46839] New: Parser confuses derived member with std::forward foehst at informatik dot uni-kl.de
@ 2010-12-07 17:12 ` foehst at informatik dot uni-kl.de
2010-12-07 17:20 ` paolo.carlini at oracle dot com
2010-12-07 17:25 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: foehst at informatik dot uni-kl.de @ 2010-12-07 17:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46839
--- Comment #1 from Tobias Föhst <foehst at informatik dot uni-kl.de> 2010-12-07 17:12:45 UTC ---
I forgot: Line 15 is only there to prove that this->forward with another
successor than '<' can be resolved as the member derived from A<T>.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/46839] Parser confuses derived member with std::forward
2010-12-07 17:02 [Bug c++/46839] New: Parser confuses derived member with std::forward foehst at informatik dot uni-kl.de
2010-12-07 17:12 ` [Bug c++/46839] " foehst at informatik dot uni-kl.de
@ 2010-12-07 17:20 ` paolo.carlini at oracle dot com
2010-12-07 17:25 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2010-12-07 17:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46839
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2010-12-07 17:19:42 UTC ---
Note that Intel compiler, based on the EDG C++ front-end, also rejects this
code in strict mode. Likewise of course Comeau. This is enough to show the
issue:
template<typename T>
void forward(T);
template <typename T> struct A
{
T forward;
};
template <typename T> struct B : public A<T>
{
void Function()
{
this->forward < 1;
}
};
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/46839] Parser confuses derived member with std::forward
2010-12-07 17:02 [Bug c++/46839] New: Parser confuses derived member with std::forward foehst at informatik dot uni-kl.de
2010-12-07 17:12 ` [Bug c++/46839] " foehst at informatik dot uni-kl.de
2010-12-07 17:20 ` paolo.carlini at oracle dot com
@ 2010-12-07 17:25 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-12-07 17:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46839
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-12-07 17:24:19 UTC ---
See PR 20308 and such.
*** This bug has been marked as a duplicate of bug 20308 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-12-07 17:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-07 17:02 [Bug c++/46839] New: Parser confuses derived member with std::forward foehst at informatik dot uni-kl.de
2010-12-07 17:12 ` [Bug c++/46839] " foehst at informatik dot uni-kl.de
2010-12-07 17:20 ` paolo.carlini at oracle dot com
2010-12-07 17:25 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).