c++ - On-demand instantiation bug?
- Radovan Zach (43/43) Aug 31 2008 Hello,
- Walter Bright (2/2) Sep 14 2008 Added as:
Hello, 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 free. Is it a bug then? #define FAIL template<bool b> struct HaltNow; template<> struct HaltNow<false> {}; template<typename T> struct Something { Something(void){} #if defined(FAIL) Something(const Something& var); #else Something(const Something& var) { HaltNow<true> halt; } #endif }; #if defined(FAIL) template<typename T> Something<T>::Something(const Something& var) { HaltNow<true> halt; } #endif int main(void) { Something<int> some_traits; return 0; } Thank you, Radovan
Aug 31 2008
Added as: http://bugzilla.digitalmars.com/issues/show_bug.cgi?id=25
Sep 14 2008