public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Bug report
@ 1998-12-10 12:43 Karl JH Millar
1998-12-10 15:55 ` Alexandre Oliva
1998-12-10 15:55 ` Explict typename Gerald Pfeifer
0 siblings, 2 replies; 4+ messages in thread
From: Karl JH Millar @ 1998-12-10 12:43 UTC (permalink / raw)
To: egcs-bugs
I get a compiler error compiling the following
template<class I, class J>
class Map {
public:
typedef I* iterator;
};
template<class T>
void foo(T a) {
Map<int, T>::iterator i;
}
void bar() {
int x;
foo(x);
}
The result of trying to compile is
gcc -c -v template.cc -pedantic
Reading specs from /usr/local/lib/gcc-lib/i686-linux-gnu/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
/usr/local/lib/gcc-lib/i686-linux-gnu/egcs-2.91.57/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -pedantic -Asystem(unix) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ template.cc /tmp/ccP2gdme.ii
GNU CPP version egcs-2.91.57 19980901 (egcs-1.1 release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include/g++
/usr/local/include
/usr/local/i686-linux-gnu/include
/usr/local/lib/gcc-lib/i686-linux-gnu/egcs-2.91.57/include
/usr/include
End of search list.
/usr/local/lib/gcc-lib/i686-linux-gnu/egcs-2.91.57/cc1plus /tmp/ccP2gdme.ii -quiet -dumpbase template.cc -pedantic -version -o /tmp/cc3GC1hi.s
GNU C++ version egcs-2.91.57 19980901 (egcs-1.1 release) (i686-linux-gnu) compiled by GNU C version egcs-2.91.57 19980901 (egcs-1.1 release).
template.cc: In function `void foo(T)':
template.cc:9: parse error before `;'
I don't get the error compiling without -pedantic.
My system is a Linux/GNU system, (version 2.1.125 of the kernel) running on a
Cyrix PR 200MX processor. The egcs version is egcs-1.1a (egcs-2.91.57 19980901)
I don't know off hand the options I passed to configure, but it was nothing
unusual.
Karl Millar.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug report
1998-12-10 12:43 Bug report Karl JH Millar
@ 1998-12-10 15:55 ` Alexandre Oliva
1998-12-10 15:55 ` Explict typename Gerald Pfeifer
1 sibling, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 1998-12-10 15:55 UTC (permalink / raw)
To: Karl JH Millar; +Cc: egcs-bugs
On Dec 10, 1998, Karl JH Millar <kmillar@MIT.EDU> wrote:
> template<class T>
> void foo(T a) {
> Map<int, T>::iterator i;
^ you need the `typename' keyword here
--
Alexandre Oliva http://www.dcc.unicamp.br/~oliva aoliva@{acm.org}
oliva@{dcc.unicamp.br,gnu.org,egcs.cygnus.com,samba.org}
Universidade Estadual de Campinas, SP, Brasil
^ permalink raw reply [flat|nested] 4+ messages in thread
* Explict typename
1998-12-10 12:43 Bug report Karl JH Millar
1998-12-10 15:55 ` Alexandre Oliva
@ 1998-12-10 15:55 ` Gerald Pfeifer
1998-12-11 5:11 ` Gabriel Dos Reis
1 sibling, 1 reply; 4+ messages in thread
From: Gerald Pfeifer @ 1998-12-10 15:55 UTC (permalink / raw)
To: Karl JH Millar; +Cc: egcs-bugs, Mark Mitchell, Jason Merrill
On Thu, 10 Dec 1998, Karl JH Millar wrote:
> template<class T>
> void foo(T a) {
> Map<int, T>::iterator i;
> }
>
> gcc -c -v template.cc -pedantic
>
> I don't get the error compiling without -pedantic.
Your code is in error but this bug is only detected with -pedantic.
Correctly you should have written: typename Map<int, T>::iterator i.
To our C++ experts: This is reported over and over again, so I strongly
suggest that
o the implicit typename extension issues a warning whenever it comes
into play.
o a better error message is issued instead of "parse error" when
-pedantic is used.
Gerald
--
Gerald Pfeifer (Jerry) Vienna University of Technology
pfeifer@dbai.tuwien.ac.at http://www.dbai.tuwien.ac.at/~pfeifer/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Explict typename
1998-12-10 15:55 ` Explict typename Gerald Pfeifer
@ 1998-12-11 5:11 ` Gabriel Dos Reis
0 siblings, 0 replies; 4+ messages in thread
From: Gabriel Dos Reis @ 1998-12-11 5:11 UTC (permalink / raw)
To: Gerald Pfeifer; +Cc: Karl JH Millar, egcs-bugs, Mark Mitchell, Jason Merrill
>>>>> Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> wrote:
> On Thu, 10 Dec 1998, Karl JH Millar wrote:
>> template<class T>
>> void foo(T a) {
>> Map<int, T>::iterator i;
>> }
>>
>> gcc -c -v template.cc -pedantic
>>
>> I don't get the error compiling without -pedantic.
> Your code is in error but this bug is only detected with -pedantic.
> Correctly you should have written: typename Map<int, T>::iterator i.
> To our C++ experts: This is reported over and over again, so I strongly
> suggest that
> o the implicit typename extension issues a warning whenever it comes
> into play.
I recall having made suggestions along these lines a long time ago but...
> o a better error message is issued instead of "parse error" when
> -pedantic is used.
I agree.
-- Gaby
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1998-12-11 5:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-12-10 12:43 Bug report Karl JH Millar
1998-12-10 15:55 ` Alexandre Oliva
1998-12-10 15:55 ` Explict typename Gerald Pfeifer
1998-12-11 5:11 ` Gabriel Dos Reis
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).