public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: "Benoit Sevigny" <benoitsevigny@hotmail.com>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: c++/8876: wrong template instantiation
Date: Mon, 09 Dec 2002 18:26:00 -0000	[thread overview]
Message-ID: <20021210022602.2406.qmail@sources.redhat.com> (raw)

The following reply was made to PR c++/8876; it has been noted by GNATS.

From: "Benoit Sevigny" <benoitsevigny@hotmail.com>
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
 
 <html><div style='background-color:'><DIV>
 <P>Thanks for the quick reply.</P>
 <P>Here's the offending code.<BR></P></DIV>
 <P>Regards</P>
 <DIV></DIV>
 <P>Benoit Sevigny</P>
 <P><BR>&nbsp;</P>
 <DIV></DIV>
 <DIV></DIV>
 <DIV></DIV>
 <DIV></DIV>
 <DIV></DIV>&gt;From: bangerth@dealii.org 
 <DIV></DIV>
 <DIV></DIV>&gt;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 
 <DIV></DIV>
 <DIV></DIV>&gt;To: benoitsevigny@hotmail.com, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org 
 <DIV></DIV>
 <DIV></DIV>&gt;Subject: Re: c++/8876: wrong template instantiation 
 <DIV></DIV>
 <DIV></DIV>&gt;Date: 9 Dec 2002 21:15:28 -0000 
 <DIV></DIV>
 <DIV></DIV>&gt; 
 <DIV></DIV>
 <DIV></DIV>&gt;Synopsis: wrong template instantiation 
 <DIV></DIV>
 <DIV></DIV>&gt; 
 <DIV></DIV>
 <DIV></DIV>&gt;State-Changed-From-To: open-&gt;feedback 
 <DIV></DIV>
 <DIV></DIV>&gt;State-Changed-By: bangerth 
 <DIV></DIV>
 <DIV></DIV>&gt;State-Changed-When: Mon Dec 9 13:15:26 2002 
 <DIV></DIV>
 <DIV></DIV>&gt;State-Changed-Why: 
 <DIV></DIV>
 <DIV></DIV>&gt; Your attachment got lost somehow. Could you possibly send it 
 <DIV></DIV>
 <DIV></DIV>&gt; to me so that I can attach it to the report? 
 <DIV></DIV>
 <DIV></DIV>&gt; 
 <DIV></DIV>
 <DIV></DIV>&gt; Thanks 
 <DIV></DIV>
 <DIV></DIV>&gt; Wolfgang 
 <DIV></DIV>
 <DIV></DIV>&gt; 
 <DIV></DIV>
 <DIV></DIV>&gt;http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&amp;database=gcc&amp;pr=8876 
 <DIV></DIV>
 <DIV></DIV>
 <DIV></DIV></div><br clear=all><hr>Protect your PC - <a href="http://g.msn.com/8HMHEN/2024">Click here</a> for McAfee.com VirusScan Online </html>
 ------=_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 <stdio.h>
 
 template<int l, int r> struct selector {
 	enum { SUM	= l + r, CONSTANT =	100 };
 };
 
 template<int f> struct function {
 	template<typename L, typename R> struct special {
 		static void func()
 		{
 			printf("in function<%d>: l = %d, r = %d\n", f, L::PARAM, R::PARAM);
 		}
 	};
 };
 template<> struct function<3> {
 	template<typename L, typename R> struct special {
 		static void func()
 		{
 			printf("in function<3>: l = %d, r = %d\n", f, L::PARAM, R::PARAM);
 		}
 	};
 };
 template<> struct function<100> {
 	template<typename L, typename R> struct special {
 		static void func()
 		{
 			printf("in function<100>: l = %d, r = %d\n", f, L::PARAM, R::PARAM);
 		}
 	};
 };
 
 template<int l> struct object {
 
 	enum { PARAM = l };
 
 	template<int r> inline void sum(const object<r> &arg)
 	{
 		printf("calling function<%d> -> ", selector< l, r>::SUM);
 
 		function< selector< l, r>::SUM >::special< object<l>, object<r> >::func();
 	}
 	template<int r> inline void constant(const object<r> &arg)
 	{
 		printf("calling function<%d> -> ", selector< l, r>::CONSTANT);
 
 		function< selector< l, r>::CONSTANT >::special< object<l>, object<r> 
  >::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--


             reply	other threads:[~2002-12-10  2:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-09 18:26 Benoit Sevigny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-12-09 19:06 bangerth
2002-12-09 13:15 bangerth
2002-12-08 15:06 benoitsevigny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021210022602.2406.qmail@sources.redhat.com \
    --to=benoitsevigny@hotmail.com \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).