public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/8858: Gcc "rebinds" template member names.
@ 2002-12-09 11:29 bangerth
0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2002-12-09 11:29 UTC (permalink / raw)
To: eivuokko, gcc-bugs, gcc-prs, nobody
Synopsis: Gcc "rebinds" template member names.
State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Mon Dec 9 11:29:52 2002
State-Changed-Why:
Confirmed. Very wicked template magic, though.
Here's a slightly smaller testcase, failing in the wrong
place:
----------------------------------#include <cassert>
template<class T_, class U_> struct cons {};
template<class L_> struct list {
typedef L_ type;
template<class T_> class add : public ::list< ::cons<T_, L_> > {};
};
template<class T1_,class T2_> struct IsSame { enum { Value = false }; };
template<class T_> struct IsSame<T_,T_> { enum { Value = true } ; };
int main() {
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 ));
}
------------------------------
This never went right, at least not back to 2.95.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8858
^ permalink raw reply [flat|nested] 2+ messages in thread
* c++/8858: Gcc "rebinds" template member names.
@ 2002-12-07 6:36 eivuokko
0 siblings, 0 replies; 2+ messages in thread
From: eivuokko @ 2002-12-07 6:36 UTC (permalink / raw)
To: gcc-gnats
>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 ));
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-12-09 19:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-09 11:29 c++/8858: Gcc "rebinds" template member names bangerth
-- strict thread matches above, loose matches on Subject: below --
2002-12-07 6:36 eivuokko
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).