public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Kretschel Klaus <kkre@darwin.af.op.dlr.de> To: gcc-gnats@gcc.gnu.org Subject: c++/6023: Valid template code does not compile Date: Thu, 21 Mar 2002 02:06:00 -0000 [thread overview] Message-ID: <200203211004.g2LA4QT03526@darwin.af.op.dlr.de> (raw) >Number: 6023 >Category: c++ >Synopsis: Valid template code does not compile >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Thu Mar 21 02:06:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Klaus Kretschel >Release: 3.0.4 >Organization: DLR >Environment: System: Linux darwin 2.4.4-64GB-SMP #1 SMP Wed May 16 01:20:45 GMT 2001 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ./configure >Description: The call h->do_calc from Otto::calc in test program below gives the parse error temp_test.cc: In member function `T Otto<T>::calc(VEC)': temp_test.cc:35: parse error before `;' token while the same syntax is correct when called from Hugo::calc. I cannot rule out that this might be covered by the missing feature "Two stage lookup in templates is not implemented" but I don't think so. Compiler call was "g++ -c -Wall temp_test.cc". >How-To-Repeat: Test program temp_test.ii (the "vektor" struct can as well be replaced by vector; it was only introduced to avoid lots of preprocessor output): # 1 "temp_test.cc" template<class V> struct vektor { V a; vektor(V v) : a(v) {} }; template<class T> struct Otto; template<class T> struct Hugo { template<class VEC> T calc(VEC x) { T tmp; tmp = this->do_calc<VEC>(x); return tmp; } template<class VEC> T do_calc(const typename Otto<T>::MyTraits<T, VEC>::T2& x) { return x.a; } }; template<class T> struct Otto { template<class T0, typename T1> struct MyTraits; template<class T0> struct MyTraits<T0, vektor<T0> > { typedef vektor<T0> T2; }; template<class VEC> T calc(VEC x) { Hugo<T>* h; T tmp; tmp = h->calc<VEC>(x); tmp = h->do_calc<VEC>(x); return tmp; } }; int main() { vektor<char> c('X'); Otto<char> otto; otto.calc(c); } >Fix: Have an intermediate method that calls method from inside class (like "Hugo::calc" in test program). Possible but very unsatifying because of redundant code. >Release-Note: >Audit-Trail: >Unformatted:
reply other threads:[~2002-03-21 10:06 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200203211004.g2LA4QT03526@darwin.af.op.dlr.de \ --to=kkre@darwin.af.op.dlr.de \ --cc=Klaus.Kretschel@dlr.de \ --cc=gcc-gnats@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).