This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/9510: Compilation fails when calling member function templated on integer


>Number:         9510
>Category:       c++
>Synopsis:       Compilation fails when calling member function templated on integer
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 30 17:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     morgan@sten.sunnybrook.utoronto.ca
>Release:        version 3.2
>Organization:
>Environment:
Mandrake Linux 9.0
>Description:
Following code fails to compile when trying to pass an integer template parameter to a templated member function.  (This compiles succesfully on MSVC 7)


struct MyStruct
{
	template <int I_>
	int TemplatedMemberFunction()
	{
		return I_;
	}
};

template <int I_>
void TemplatedFunction()
{
	MyStruct ms;
	ms.TemplatedMemberFunction<1>();//doesn't compile.
	ms.TemplatedMemberFunction<I_>();//doesn't compile.
};

int main(int argc , char** argv)
{
	MyStruct ms;
	ms.TemplatedMemberFunction<1>();//compiles.
	TemplatedFunction<1>();			//compiles
	return 0;
}
>How-To-Repeat:
try compiling above code with g++
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="templates.ii"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="templates.ii"

IyAxICJ0ZW1wbGF0ZXMuY2MiCiMgMSAiPGJ1aWx0LWluPiIKIyAxICI8Y29tbWFuZCBsaW5lPiIK
IyAxICJ0ZW1wbGF0ZXMuY2MiCnN0cnVjdCBNeVN0cnVjdAp7CiAgICAgICAgdGVtcGxhdGUgPGlu
dCBJXz4KICAgICAgICBpbnQgVGVtcGxhdGVkTWVtYmVyRnVuY3Rpb24oKQogICAgICAgIHsKICAg
ICAgICAgICAgICAgIHJldHVybiBJXzsKICAgICAgICB9Cn07Cgp0ZW1wbGF0ZSA8aW50IElfPgp2
b2lkIFRlbXBsYXRlZEZ1bmN0aW9uKCkKewogICAgICAgIE15U3RydWN0IG1zOwogICAgICAgIG1z
LlRlbXBsYXRlZE1lbWJlckZ1bmN0aW9uPDE+KCk7CiAgICAgICAgbXMuVGVtcGxhdGVkTWVtYmVy
RnVuY3Rpb248SV8+KCk7Cn07CgppbnQgbWFpbihpbnQgYXJnYyAsIGNoYXIqKiBhcmd2KQp7CiAg
ICAgICAgTXlTdHJ1Y3QgbXM7CiAgICAgICAgbXMuVGVtcGxhdGVkTWVtYmVyRnVuY3Rpb248MT4o
KTsKICAgICAgICBUZW1wbGF0ZWRGdW5jdGlvbjwxPigpOwogICAgICAgIHJldHVybiAwOwp9Cg==


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]