public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57783] New: Silly instantiation of class template when using dependent type
@ 2013-07-02 16:58 ibugs at qult dot net
2013-07-02 17:06 ` [Bug c++/57783] " redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: ibugs at qult dot net @ 2013-07-02 16:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57783
Bug ID: 57783
Summary: Silly instantiation of class template when using
dependent type
Product: gcc
Version: 4.4.7
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ibugs at qult dot net
The following code fails to compile on GCC 4.4.7, while it succeeds on 3.3.6,
4.5.3, 4.6.3, 4.6.4 and 4.7.3.
template <class T1, class T2>
struct Two {
T1 a;
T2 b;
Two(const T1& a_, const T2& b_) : a(a_), b(b_) {}
template <class U1, class U2>
Two(const Two<U1, U2>& t) : a(t.a), b(t.b) {}
};
template <class T1, class T2>
Two<T1, T2> make_two(T1 a, T2 b) {
return Two<T1, T2>(a, b);
}
struct Empty {};
template <class Base>
struct Foo : Base {
typedef bool type;
Two<bool, type*> f();
};
template <class Base>
Two<bool, typename Foo<Base>::type*>
Foo<Base>::f() {
return make_two(false, (type*) 0);
}
int main()
{
Foo<Empty>().f();
return 0;
}
Apparently the instantiation mechanism somehow has trouble dealing with
Foo<Base>::type and doesn't identify this with the exact type (bool).
The very curious fact is that the error message starts with:
In instantiation of 'Foo<bool>':
which makes me wonder, how comes GCC wants to instantiate a class template with
some completely random parameter.
This seems to be fixed in later releases, but I haven't been able to pinpoint
the actual report and fix. So I report that specific case just to be sure that
problem won't resurrect in the future.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/57783] Silly instantiation of class template when using dependent type
2013-07-02 16:58 [Bug c++/57783] New: Silly instantiation of class template when using dependent type ibugs at qult dot net
@ 2013-07-02 17:06 ` redi at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2013-07-02 17:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57783
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
GCC 4.4 is no longer supported or maintained, but as you say it works in
currently supported versions.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-07-02 17:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-02 16:58 [Bug c++/57783] New: Silly instantiation of class template when using dependent type ibugs at qult dot net
2013-07-02 17:06 ` [Bug c++/57783] " redi at gcc dot gnu.org
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).