Created attachment 28518 [details] Sample code The attached test file produces with "g++ -c test.cc" of GCC version 4.7 (e.g. the one shipped with OpenSuse 12.2) and 4.8 the following output: test.cc: In constructor 'C_DrvDataBuffer::C_DrvDataBuffer(ushort, ushort)': test.cc:20748:34: error: invalid conversion from 'const T_SND_NODE C_DrvSndDataBlock::* {aka const list_node<C_DrvSndDataBlock, with_lock, oper_safe> C_DrvSndDataBlock::*}' to 'list_node<C_DrvSndDataBlock, with_lock, oper_safe> C_DrvSndDataBlock::*' [-fpermissive] test.cc:16667:1: error: initializing argument 1 of 'list_base< <template-parameter-1-1>, <template-parameter-1-2>, test_, amp_>::list_base(const T_C_NODE_ T_::*, const char*, bool) [with T_ = C_DrvSndDataBlock; lock_ = with_lock; test_ = oper_safe; bool amp_ = false; list_base< <template-parameter-1-1>, <template-parameter-1-2>, test_, amp_>::T_C_NODE_ = list_node<C_DrvSndDataBlock, with_lock, oper_safe>]' [-fpermissive] test.cc:20748:34: error: invalid conversion from 'const T_SND_NODE C_DrvSndDataBlock::* {aka const list_node<C_DrvSndDataBlock, with_lock, oper_safe> C_DrvSndDataBlock::*}' to 'list_node<C_DrvSndDataBlock, with_lock, oper_safe> C_DrvSndDataBlock::*' [-fpermissive] test.cc:16667:1: error: initializing argument 1 of 'list_base< <template-parameter-1-1>, <template-parameter-1-2>, test_, amp_>::list_base(const T_C_NODE_ T_::*, const char*, bool) [with T_ = C_DrvSndDataBlock; lock_ = with_lock; test_ = oper_safe; bool amp_ = false; list_base< <template-parameter-1-1>, <template-parameter-1-2>, test_, amp_>::T_C_NODE_ = list_node<C_DrvSndDataBlock, with_lock, oper_safe>]' [-fpermissive] test.cc:20748:34: error: invalid conversion from 'const T_RCV_NODE C_DrvRcvDataBlock::* {aka const list_node<C_DrvRcvDataBlock, with_lock, oper_safe> C_DrvRcvDataBlock::*}' to 'list_node<C_DrvRcvDataBlock, with_lock, oper_safe> C_DrvRcvDataBlock::*' [-fpermissive] test.cc:16667:1: error: initializing argument 1 of 'list_base< <template-parameter-1-1>, <template-parameter-1-2>, test_, amp_>::list_base(const T_C_NODE_ T_::*, const char*, bool) [with T_ = C_DrvRcvDataBlock; lock_ = with_lock; test_ = oper_safe; bool amp_ = false; list_base< <template-parameter-1-1>, <template-parameter-1-2>, test_, amp_>::T_C_NODE_ = list_node<C_DrvRcvDataBlock, with_lock, oper_safe>]' [-fpermissive] The test code can be compiled with the Comeau-Online-Compiler: http://www.comeaucomputing.com/tryitout The GCC 4.6 works also.
can you reduce it to get rid of all the code that doesn't affect the failure?
(In reply to comment #1) > can you reduce it to get rid of all the code that doesn't affect the failure? I already reduced it quite a lot, but I try harder tomorrow.
Created attachment 28527 [details] Reduced smaple code. This is the offending code reduced to the minimum. The error is no longer present, that means the surrounding code has an effect.
(In reply to comment #3) > The error is no longer > present, Then the attachment isn't very useful. It needs to be reduced to the minimum that still shows the bug, otherwise it's just some code. http://gcc.gnu.org/bugs/minimize.html
Created attachment 28537 [details] Test case. Thanks for the hint to the delta tool. This is great for automatic test case reduction. The test code is now: template <typename T> struct A { }; template <typename T> struct B { B(const A<T> T::* p); typedef A<T> D; }; template <typename T> B<T>::B(const D T::* p) { } struct C { C() : e() {}; const A<C> e; }; B<C> g(&C::e); The crucial thing is the "typedef A<T> D". It works, if we move it before the constructor declaration "B(const A<T> T::* p)". Removing the constructor definition works also.
If I revert parts of commit 44f861fca343148a1b0720105ec2b7f14bbcc849 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1ff1c73..8f5b9f7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11015,9 +11015,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) complain | tf_ignore_bad_quals); return r; } - else - /* We don't have an instantiation yet, so drop the typedef. */ - t = DECL_ORIGINAL_TYPE (decl); + /* Else we must be instantiating the typedef, so fall through. */ } if (type mentioned in http://gcc.gnu.org/ml/gcc/2012-10/msg00399.html then, the test case compiles well.
*** Bug 55097 has been marked as a duplicate of this bug. ***
Author: jason Date: Fri Dec 7 04:53:59 2012 New Revision: 194282 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194282 Log: PR c++/55058 * pt.c (tsubst): Keep the quals when looking through a typedef. Added: trunk/gcc/testsuite/g++.dg/template/typedef40.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c
Author: jason Date: Fri Dec 7 05:13:22 2012 New Revision: 194289 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194289 Log: PR c++/55058 * pt.c (tsubst): Keep the quals when looking through a typedef. Added: branches/gcc-4_7-branch/gcc/testsuite/g++.dg/template/typedef40.C Modified: branches/gcc-4_7-branch/gcc/cp/ChangeLog branches/gcc-4_7-branch/gcc/cp/pt.c
Fixed.