C++ static template function causes armcc compilation error (304) -


i have tested compilation of following code on both vs10 , armcc4.1 [build 561]. both functions depth1() , depth2() compile on vs, armcc compile depth1() while giving error 304 (no instance of matches argument list) depth2(). when foo , bar non-static, compiles fine on armcc well.

i'd happy understand why.

template <class t> static t foo(t arg) {    return arg*5; }  template <class t> static t bar(t arg) {    return foo<t>(arg); }  void depth2() {    int = 12;    = bar<int>(i); }  void depth1() {    int = 12;    = foo<int>(i); } 

per comments above: appears bug in armcc 4.1.

if employer has support contract arm, can raise support issue arm here: http://www.arm.com/support/obtaining-support/index.php (click "development tools" tab , big blue "raise support case" button).

as workarounds, might try

  • rearranging definitions of foo , bar in source file; and/or
  • providing forward declaration foo and/or bar somewhere prior definition; and/or
  • adding explicit instantiation of foo<int> somewhere after declaration, this:

    template int foo(int arg); // or, if style better, template int foo<int>(int arg); 

Comments