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

Re: possible bug in g++


On 15/02/2012, Mattia Jona-Lasinio <mattia.jona@gmail.com> wrote:
> Hi list,
>
> the following code does not link with g++ 4.3.2 but works with the
> intel compiler version 11.0
>
> #include <iostream>
>
> template <int T = 5>
> struct X
> {
> 	static const int v = T*X<T-1>::v;
> };
>
> template <>
> struct X<0>
> {
> 	static const int v = 1;
> };
>
> template <typename T>
> T *aa(int n)
> {
> 	return (new T[n]);
> }
>
> int main()
> {
> 	X<4> *b;
>
> 	std::cout << (b = aa< X<4> >(3))[1].v << std::endl; // relevant line
>
> 	delete[] b;
>
> 	return 0;
> }
>
> Also the following shorter version does not link with g++
>
> int main()
> {
> 	std::cout << aa< X<4> >(3)[1].v << std::endl; // relevant line
>
> 	return 0;
> }
>
> while the following version links with g++ though all versions must be
> equivalent. Am I missing something?
>
> int main()
> {
> 	X<4> *b;
>
> 	b = aa< X<4> >(3); // relevant line
> 	std::cout << b[1].v << std::endl; // relevant line
>
> 	delete[] b;
>
> 	return 0;
> }
>
>

Is this http://gcc.gnu.org/wiki/VerboseDiagnostics#undefined_reference_to_.60S::a.27


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