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]

Possible bug in g++ - template specialization


Hi,

I think I've found a bug in g++. Let's say we have following files:

// a.hpp

template<typename T>
void func1()
{
	// general code
}

// a.cpp

#include "a.hpp"

template<>
void func1<int>()
{
	// specialized code
}

// main.cpp

#include "a.hpp"

int main(void)
{
	func1<int>();
	
	return 0;
}


Now when we run the program compiled with: g++ main.cpp a.cpp -o main
specialized version of func1 will be called, but when compiled with
-Os flag the general version will be called.
I'm not an expert but I believe the -Os behaviour is the correct one.

Please CC me when replying, as I'm not subscribed to the mailing list.

Regards,
Maciej Cencora


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