public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/38501] New: typedef confuses the name of the template and the name of result
@ 2008-12-12 1:42 resume755 at mail dot ru
2008-12-12 1:43 ` [Bug c++/38501] " resume755 at mail dot ru
2008-12-12 1:49 ` pinskia at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: resume755 at mail dot ru @ 2008-12-12 1:42 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]
typedef confuses the name of the template and the name of result:
sh-3.2$ cat tloop_iterator.h
#ifndef TLOOP_ITERATOR_H_
#define TLOOP_ITERATOR_H_
#include <list>
template<typename T>
struct loop_iterator : public T::iterator
{ };
template <typename T>
struct list : std::list<T>
{
typedef loop_iterator<list> loop_iterator;
};
#endif
Compiling this file:
sh-3.2$ g++-4.1 tloop_iterator.h
sh-3.2$ g++-4.2 tloop_iterator.h
all right, but:
sh-3.2$ g++-4.3 tloop_iterator.h
tloop_iterator.h:14: error: declaration of typedef struct
loop_iterator<list<T> > list<T>::loop_iterator
tloop_iterator.h:8: error: changes meaning of loop_iterator from struct
loop_iterator<list<T> >
sh-3.2$ g++-4.3 --version
g++-4.3 (Debian 4.3.2-1) 4.3.2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
My system is Debian GLU/Linux Lenny
Version 4.3.1 also has this problem
--
Summary: typedef confuses the name of the template and the name
of result
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: resume755 at mail dot ru
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38501
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/38501] typedef confuses the name of the template and the name of result
2008-12-12 1:42 [Bug c++/38501] New: typedef confuses the name of the template and the name of result resume755 at mail dot ru
@ 2008-12-12 1:43 ` resume755 at mail dot ru
2008-12-12 1:49 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: resume755 at mail dot ru @ 2008-12-12 1:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from resume755 at mail dot ru 2008-12-12 01:42 -------
Created an attachment (id=16896)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16896&action=view)
demo
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38501
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/38501] typedef confuses the name of the template and the name of result
2008-12-12 1:42 [Bug c++/38501] New: typedef confuses the name of the template and the name of result resume755 at mail dot ru
2008-12-12 1:43 ` [Bug c++/38501] " resume755 at mail dot ru
@ 2008-12-12 1:49 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-12-12 1:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2008-12-12 01:46 -------
No GCC 4.3 and above is doing the correct thing. This code is invalid but no
diagnostic is required by the C++ standard.
See <http://gcc.gnu.org/gcc-4.3/porting_to.html>:
Name lookup changes
GCC by default no longer accepts code such as
template <class _Tp> class auto_ptr {};
template <class _Tp>
struct counted_ptr
{
auto_ptr<_Tp> auto_ptr();
};
but will issue the diagnostic
error: declaration of 'auto_ptr<_Tp> counted_ptr<_Tp>::auto_ptr()'
error: changes meaning of 'auto_ptr' from 'class auto_ptr<_Tp>'
The reference to struct auto_ptr needs to be qualified here, or the name of the
member function changed to be unambiguous.
template <class _Tp> class auto_ptr {};
template <class _Tp>
struct counted_ptr
{
::auto_ptr<_Tp> auto_ptr();
};
In addition, -fpermissive can be used as a temporary workaround to convert the
error into a warning until the code is fixed. Note that then in some case name
lookup will not be standard conforming.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38501
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-12-12 1:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-12 1:42 [Bug c++/38501] New: typedef confuses the name of the template and the name of result resume755 at mail dot ru
2008-12-12 1:43 ` [Bug c++/38501] " resume755 at mail dot ru
2008-12-12 1:49 ` pinskia at gcc dot gnu dot 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).