This is the mail archive of the gcc@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]

static array of label addresses in function templates?


Hi,

the following code produces an error message. Is the code wrong or
I really can't have such static data in function templates?
(with an ordinary function [ int fun(int i) ] it works).

thanks,
lajos foldy


######################################################################

#include <iostream>

template<class T>
int fun(T i)
{
    static void* labs[2] = { &&lab1, &&lab2 };

    goto *(labs[i==0]);

    lab1:   return 1;
    lab2:   return 2;

    return 0;
}

int main()
{   std::cout << fun(1) << std::endl;
}

######################################################################

foldy@bombur:~> g++-3.2 a.cc
a.cc: In function `int fun(T) [with T = int]':
a.cc:18:   instantiated from here
a.cc:7: Internal compiler error in find_function_data, at function.c:329
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
foldy@bombur:~>




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