public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "wim dot yedema at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/36353] New: Unclear error message in unused template Date: Wed, 28 May 2008 07:57:00 -0000 [thread overview] Message-ID: <bug-36353-16247@http.gcc.gnu.org/bugzilla/> (raw) I get these error messages: aap.cc: In member function 'void Bar<T>::function(T)': aap.cc:16: error: expected `;' before 'it' aap.cc:18: error: 'it' was not declared in this scope When I compile this code: #include <iostream> #include <list> template<typename T> class Foo { public: void function(T arg) { std::cout << arg; } }; template<typename T> class Bar { std::list<Foo<T> *> foo_list; public: void function(T arg) { std::list<Foo<T> *>::iterator it; for (it = foo_list.begin(); it!=foo_list.end(); it++) { Foo<T> *el = (*it); el->function (arg); } } }; int main(void) { #if 0 // Enabling this gives a better error message Bar<int> bar; bar.function(1); #endif return 1; } When you enabled the #ifdeffed out code you will get these much clearer error messages too: aap.cc: In member function 'void Bar<T>::function(T) [with T = int]': aap.cc:31: instantiated from here aap.cc:16: error: dependent-name 'std::list<Foo<T>*,std::allocator<Foo<T>*> >::iterator' is parsed as a non-type, but instantiation yields a type aap.cc:16: note: say 'typename std::list<Foo<T>*,std::allocator<Foo<T>*> >::iterator' if a type is meant verbose output: trunk (--) ~/src/q/ g++ -v -save-temps aap.cc Reading specs from /sysmnt/cadappl_linuxi386_nsvr1/gcc/4.2.2.1/bin/../lib/gcc/i686-pc-linux-gnu/4.2.2/specs Target: i686-pc-linux-gnu Configured with: /home/gcc/gcc/gcc-4.2.2.1/gcc-4.2.2.1/configure --prefix=/cadappl/gcc/4.2.2.1 --with-as=/cadappl/gcc/4.2.2.1/bin/as --with-ld=/cadappl/gcc/4.2.2.1/bin/ld --enable-__cxa_atexit --enable-threads=posix --with-march=i686 --with-tune=pentium4 --enable-languages=c,c++,fortran --with-gmp=/cadappl/gcc/4.2.2.1 --with-mpfr=/cadappl/gcc/4.2.2.1 Thread model: posix gcc version 4.2.2 /sysmnt/cadappl_linuxi386_nsvr1/gcc/4.2.2.1/bin/../libexec/gcc/i686-pc-linux-gnu/4.2.2/cc1plus -E -quiet -v -iprefix /sysmnt/cadappl_linuxi386_nsvr1/gcc/4.2.2.1/bin/../lib/gcc/i686-pc-linux-gnu/4.2.2/ -D_GNU_SOURCE aap.cc -mtune=pentium4 -fpch-preprocess -o aap.ii ignoring nonexistent directory "/sysmnt/cadappl_linuxi386_nsvr1/gcc/4.2.2.1/bin/../lib/gcc/i686-pc-linux-gnu/4.2.2/../../../../i686-pc-linux-gnu/include" ignoring duplicate directory "/cadappl/gcc/4.2.2.1/lib/gcc/i686-pc-linux-gnu/4.2.2/../../../../include/c++/4.2.2" ignoring duplicate directory "/cadappl/gcc/4.2.2.1/lib/gcc/i686-pc-linux-gnu/4.2.2/../../../../include/c++/4.2.2/i686-pc-linux-gnu" ignoring duplicate directory "/cadappl/gcc/4.2.2.1/lib/gcc/i686-pc-linux-gnu/4.2.2/../../../../include/c++/4.2.2/backward" ignoring duplicate directory "/cadappl/gcc/4.2.2.1/lib/gcc/i686-pc-linux-gnu/4.2.2/include" ignoring nonexistent directory "/cadappl/gcc/4.2.2.1/lib/gcc/i686-pc-linux-gnu/4.2.2/../../../../i686-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /sysmnt/cadappl_linuxi386_nsvr1/gcc/4.2.2.1/bin/../lib/gcc/i686-pc-linux-gnu/4.2.2/../../../../include/c++/4.2.2 /sysmnt/cadappl_linuxi386_nsvr1/gcc/4.2.2.1/bin/../lib/gcc/i686-pc-linux-gnu/4.2.2/../../../../include/c++/4.2.2/i686-pc-linux-gnu /sysmnt/cadappl_linuxi386_nsvr1/gcc/4.2.2.1/bin/../lib/gcc/i686-pc-linux-gnu/4.2.2/../../../../include/c++/4.2.2/backward /sysmnt/cadappl_linuxi386_nsvr1/gcc/4.2.2.1/bin/../lib/gcc/i686-pc-linux-gnu/4.2.2/include /usr/local/include /cadappl/gcc/4.2.2.1/include /usr/include End of search list. /sysmnt/cadappl_linuxi386_nsvr1/gcc/4.2.2.1/bin/../libexec/gcc/i686-pc-linux-gnu/4.2.2/cc1plus -fpreprocessed aap.ii -quiet -dumpbase aap.cc -mtune=pentium4 -auxbase aap -version -o aap.s GNU C++ version 4.2.2 (i686-pc-linux-gnu) compiled by GNU C version 4.2.2. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 473b7610f3bef24f1da62f9e674d528f aap.cc: In member function 'void Bar<T>::function(T)': aap.cc:16: error: expected `;' before 'it' aap.cc:18: error: 'it' was not declared in this scope -- Summary: Unclear error message in unused template Product: gcc Version: 4.2.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: wim dot yedema at gmail dot com GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36353
next reply other threads:[~2008-05-28 7:57 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2008-05-28 7:57 wim dot yedema at gmail dot com [this message] 2008-05-28 8:00 ` [Bug c++/36353] missing typename for unused template error message is unclear pinskia at gcc dot gnu dot org 2008-05-28 8:01 ` pinskia at gcc dot gnu dot org 2008-05-28 8:01 ` wim dot yedema at gmail dot com 2008-05-28 8:02 ` wim dot yedema at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-36353-16247@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).