From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2421 invoked by alias); 10 Dec 2002 02:26:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 2407 invoked by uid 71); 10 Dec 2002 02:26:02 -0000 Date: Mon, 09 Dec 2002 18:26:00 -0000 Message-ID: <20021210022602.2406.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: "Benoit Sevigny" Subject: Re: c++/8876: wrong template instantiation Reply-To: "Benoit Sevigny" X-SW-Source: 2002-12/txt/msg00508.txt.bz2 List-Id: The following reply was made to PR c++/8876; it has been noted by GNATS. From: "Benoit Sevigny" To: bangerth@dealii.org, benoitsevigny@hotmail.com, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Cc: Subject: Re: c++/8876: wrong template instantiation Date: Mon, 09 Dec 2002 21:18:22 -0500 This is a multi-part message in MIME format. ------=_NextPart_000_252a_61df_4e24 Content-Type: text/html

Thanks for the quick reply.

Here's the offending code.

Regards

Benoit Sevigny


 

>From: bangerth@dealii.org
>Reply-To: bangerth@dealii.org, benoitsevigny@hotmail.com, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
>To: benoitsevigny@hotmail.com, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org
>Subject: Re: c++/8876: wrong template instantiation
>Date: 9 Dec 2002 21:15:28 -0000
>
>Synopsis: wrong template instantiation
>
>State-Changed-From-To: open->feedback
>State-Changed-By: bangerth
>State-Changed-When: Mon Dec 9 13:15:26 2002
>State-Changed-Why:
> Your attachment got lost somehow. Could you possibly send it
> to me so that I can attach it to the report?
>
> Thanks
> Wolfgang
>
>http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8876


Protect your PC - Click here for McAfee.com VirusScan Online ------=_NextPart_000_252a_61df_4e24 Content-Type: text/plain; name="gccbug.cxx"; format=flowed Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="gccbug.cxx" #include template struct selector { enum { SUM = l + r, CONSTANT = 100 }; }; template struct function { template struct special { static void func() { printf("in function<%d>: l = %d, r = %d\n", f, L::PARAM, R::PARAM); } }; }; template<> struct function<3> { template struct special { static void func() { printf("in function<3>: l = %d, r = %d\n", f, L::PARAM, R::PARAM); } }; }; template<> struct function<100> { template struct special { static void func() { printf("in function<100>: l = %d, r = %d\n", f, L::PARAM, R::PARAM); } }; }; template struct object { enum { PARAM = l }; template inline void sum(const object &arg) { printf("calling function<%d> -> ", selector< l, r>::SUM); function< selector< l, r>::SUM >::special< object, object >::func(); } template inline void constant(const object &arg) { printf("calling function<%d> -> ", selector< l, r>::CONSTANT); function< selector< l, r>::CONSTANT >::special< object, object >::func(); } }; int main(int argc, const char *argv[]) { object<1> obj1; object<2> obj2; obj1.sum(obj2); // this should print: "in function<3>: l = 1, r = 2" obj2.sum(obj1); // this should print: "in function<3>: l = 2, r = 1" obj1.constant(obj2); // this should print: "in function<100>: l = 1, r = 2" obj2.constant(obj1); // this should print: "in function<100>: l = 2, r = 1" return 0; } ------=_NextPart_000_252a_61df_4e24--