www.digitalmars.com         C & C++   DMDScript  

c++ - On-demand instantiation bug?

reply Radovan Zach <radovan.zach quick.cz> writes:
 if you compile the following code with DMC 8.42n, the compiler will issue
"Error: size of ?$HaltNow $00 is not known".

If you comment out the initial "#define FAIL" line it compiles alright. As
there is no reference to Something's copy constructor in the main(void)
function I think the compiler should disregard its definition in both cases
and hence always succeed.

The code snippet compilation with GCC 3.45, Intel 10.1 and MS VC 8.1. is error

Is it a bug then?

#define FAIL

template<bool b>
struct HaltNow;

struct HaltNow<false>

template<typename T>
struct Something


#if defined(FAIL)
	Something(const Something& var);
	Something(const Something& var)
		HaltNow<true> halt;

#if defined(FAIL)
template<typename T>
Something<T>::Something(const Something& var)
	HaltNow<true> halt;

int main(void)
	Something<int> some_traits;
	return 0;

Thank you,
Aug 31 2008
parent Walter Bright <newshound1 digitalmars.com> writes:
Added as:

Sep 14 2008