Template function with default argument in a Template class

Kamis, 26 Mei 2011

Reference Number : 


Version : 

Intel C++ compiler 12.0.

Operating System : 

Mac OS

Problem Description : 

Intel C++ compiler fails with internal error when Template function with default argument in is in a Template class.

We get an internal error when trying to compile the test case below. It compiles with without error when using Apple GCC 4.2.1, GNU GCC 4.5.2, clang++ 2.8, and Intel 11.1 091.

I am trying to pass a member function pointer (&C2::func2) to a template member template function (C2::Tfunc), where the template function argument for the member-function-pointer type is a template argument. This fails if the member function pointer is for a function that has a default argument and the class that contains the member function is also a template.

Class C1 shows that this works just fine when the class is not a template class. Class C2 shows that it works for a function where the argument does not have a default value, but does fail when the function has a default argument.

// tstcase.cpp  #include <stdio.h>  #include <stdlib.h>  class C1 {  public:    int func1(int i) {      return i;    }    int func2(int i = int()) {      return i;    }    template <typename F, typename A>    A Tfunc(F f, A a) {      return a;    }    int test() {      int i = int();      int j = this->Tfunc(&C1::func1, i); // OK      int k = this->Tfunc(&C1::func2, j); // OK      return k;    }  };  template <typename X>  class C2 {  public:    X func1(X i) {      return i;    }    X func2(X i = X()) {      return i;    }    template <typename F, typename A>    A Tfunc(F f, A a) {      return a;    }    X test() {      X i = X();      X j = this->Tfunc(&C2<X>::func1, i); // OK without default argument value      X k = this->Tfunc(&C2<X>::func2, j); // Error: Template class with function                                           // pointer to a function with default value      return k;    }  };  int main(void) {    C1 c1;    c1.test();    C2<int> c2;    c2.test();    return EXIT_SUCCESS;  }  

$ icc -O0 -c tstcase.cpp
tstcase.cpp(38): internal error: assertion failed: instantiate_default_arguments_of_template_matching: template not found (shared/edgcpfe/overload.c, line 5225)

X k = this->Tfunc(&C2<X>::func2, j); // Error: Template class with function

compilation aborted for tstcase.cpp (code 4)

$ icc -V
Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version Build 20101110
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.

$ g++ -O0 -c tstcase.cpp

Resolution Status : 

The issue is fixed in Intel C++ compiler 12.0 update 4.

[DISCLAIMER: The information on this web site is intended for hardware system manufacturers and software developers. Intel does not warrant the accuracy, completeness or utility of any information on this site. Intel may make changes to the information or the site at any time without notice. Intel makes no commitment to update the information at this site. ALL INFORMATION PROVIDED ON THIS WEBSITE IS PROVIDED "as is" without any express, implied, or statutory warranty of any kind including but not limited to warranties of merchantability, non-infringement of intellectual property, or fitness for any particular purpose. Independent companies manufacture the third-party products that are mentioned on this site. Intel is not responsible for the quality or performance of third-party products and makes no representation or warranty regarding such products. The third-party supplier remains solely responsible for the design, manufacture, sale and functionality of its products. Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. *Other names and brands may be claimed as the property of others.]

25 May, 2011


0 komentar:

Posting Komentar

Ayo gan Komentarnya jangan lupa,,,biar tambah semangat yang upload Film dan Game dan berita juga update artikelnya, kalau ada link yang mati laporkan juga disini ya...

gamers holic dan security web dan aneka ragam © 2011 | Designed by Bingo Cash, in collaboration with Modern Warfare 3, VPS Hosting and Compare Web Hosting
Related Posts Plugin for WordPress, Blogger...