public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/39321] New: G++ remove cv qualifiers from typedefs during template instantiation
@ 2009-02-27 20:05 dodji at gcc dot gnu dot org
2009-02-27 20:06 ` [Bug c++/39321] " dodji at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: dodji at gcc dot gnu dot org @ 2009-02-27 20:05 UTC (permalink / raw)
To: gcc-bugs
The following program should compile, but current g++ from trunk compiles it.
Please read the comments in the code:
~=~
template<typename T>
struct do_typedef
{
typedef T type;
};
template<typename T> struct is_function;
// Let's name this template partial specialization #1
template<typename T>
struct is_function< T ()>
{
};
template<typename T> struct is_member_func;
template<typename T, typename C>
struct is_member_func<T C::*>
{
//[1] okay, the following line should not compile. Here is why.
//After the type substitution that happens at instantiation time,
//the value of the argument that matches the T parameter is
//'void () () const'.
//In that context, the result of the substitution of T in the expression
//do_typedef<T>::type _should_ be 'void () () const' as well.
//So will be the argument of the is_function template.
//'void () () const' is not compatible with 'T ()', so the
//partial template specialization #1 should be instantiated.
//So we should get a compilation error.
is_function<typename do_typedef<T>::type> t;
};
struct A;
// Should not compile because of the comment [1] above.
is_member_func<void (A::*) (void) const> t;
~=~
What happens is that during the type substitution of
do_typedef<T>::type, g++ removes the const qualifier from the 'void () ()
const' function. And that is a bug.
I'll attach below a patch that fixes it.
--
Summary: G++ remove cv qualifiers from typedefs during template
instantiation
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dodji at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39321
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/39321] G++ remove cv qualifiers from typedefs during template instantiation
2009-02-27 20:05 [Bug c++/39321] New: G++ remove cv qualifiers from typedefs during template instantiation dodji at gcc dot gnu dot org
@ 2009-02-27 20:06 ` dodji at gcc dot gnu dot org
2009-02-28 8:09 ` pinskia at gcc dot gnu dot org
2009-03-02 1:22 ` jason at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: dodji at gcc dot gnu dot org @ 2009-02-27 20:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from dodji at gcc dot gnu dot org 2009-02-27 20:06 -------
Created an attachment (id=17372)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17372&action=view)
Don't remove cv quals from typedefs during type substitution
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39321
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/39321] G++ remove cv qualifiers from typedefs during template instantiation
2009-02-27 20:05 [Bug c++/39321] New: G++ remove cv qualifiers from typedefs during template instantiation dodji at gcc dot gnu dot org
2009-02-27 20:06 ` [Bug c++/39321] " dodji at gcc dot gnu dot org
@ 2009-02-28 8:09 ` pinskia at gcc dot gnu dot org
2009-03-02 1:22 ` jason at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-02-28 8:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2009-02-28 08:09 -------
This is related to bug 37806.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39321
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/39321] G++ remove cv qualifiers from typedefs during template instantiation
2009-02-27 20:05 [Bug c++/39321] New: G++ remove cv qualifiers from typedefs during template instantiation dodji at gcc dot gnu dot org
2009-02-27 20:06 ` [Bug c++/39321] " dodji at gcc dot gnu dot org
2009-02-28 8:09 ` pinskia at gcc dot gnu dot org
@ 2009-03-02 1:22 ` jason at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-03-02 1:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jason at gcc dot gnu dot org 2009-03-02 01:22 -------
Yep, duplicate.
*** This bug has been marked as a duplicate of 37806 ***
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39321
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-03-02 1:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-27 20:05 [Bug c++/39321] New: G++ remove cv qualifiers from typedefs during template instantiation dodji at gcc dot gnu dot org
2009-02-27 20:06 ` [Bug c++/39321] " dodji at gcc dot gnu dot org
2009-02-28 8:09 ` pinskia at gcc dot gnu dot org
2009-03-02 1:22 ` jason at gcc dot gnu dot 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).