public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: eivuokko@bonumit.com To: gcc-gnats@gcc.gnu.org Subject: c++/8858: Gcc "rebinds" template member names. Date: Sat, 07 Dec 2002 06:36:00 -0000 [thread overview] Message-ID: <20021207143500.27732.qmail@sources.redhat.com> (raw) >Number: 8858 >Category: c++ >Synopsis: Gcc "rebinds" template member names. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Sat Dec 07 06:36:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: eivuokko@bonumit.com >Release: gcc-3.2 >Organization: >Environment: (also tried with rc version of mingw-gcc 3.2.1) C:\base\test>g++ -v Reading specs from c:/devel/mingw/bin/../lib/gcc-lib/mingw32/3.2/specs Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host= mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable -languages=f77,c++,objc,ada --disable-win32-registry --disable-shared Thread model: win32 gcc version 3.2 (mingw special 20020817-1) >Description: If you have type inside a template, issuing last template-id as member of it rebinds the template instead of using previous type. ie typedef foo::bar<int>::bar<float> baz; generates same effect as typedef foo::bar<float> baz; >How-To-Repeat: example session, program asserts in unexpected place, it should assert before, for difffrent type. C:\base\test>g++ gcc_rebind_bug.cpp -o gcc_rebind_bug -Wall && gcc_rebind_bug Assertion failed: ( IsSame< cons<int, cons<char, cons<double,float> > >, test_ty pe>::Value ), file gcc_rebind_bug.cpp, line 37 >Fix: Haven't found one yet, except moving member template outside the class. >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="gcc_rebind_bug.cpp" Content-Disposition: inline; filename="gcc_rebind_bug.cpp" #include <cassert> template<class T_, class U_> class cons {}; template<class L_> class list { public: typedef L_ type; template<class T_> class add : public ::list< ::cons<T_, L_> > {}; } ; template<class T1_,class T2_> class IsSame { public: enum { Value = false } ; } ; template<class T_> class IsSame<T_,T_> { public: enum { Value = true } ; } ; int main() { // assure IsSame works assert(( IsSame<int,int>::Value )); assert(( IsSame<float,float>::Value )); assert(( IsSame<cons<int,cons<char,float> >,cons<int,cons<char,float> > >::Value )); // real test typedef list<cons<double,float> >::add<char>::add<int>::type test_type; // this should absolutely fail assert(( IsSame< cons<int, cons<double,float> >, test_type>::Value )); // and this shouldn't assert(( IsSame< cons<int, cons<char, cons<double,float> > >, test_type>::Value )); }
next reply other threads:[~2002-12-07 14:36 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-12-07 6:36 eivuokko [this message] 2002-12-09 11:29 bangerth
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=20021207143500.27732.qmail@sources.redhat.com \ --to=eivuokko@bonumit.com \ --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).