-
Internal Compiler Error
I did it again - what most people have problems with or simply cannot replicate.
I made Microsoft's compiler crash! :)
1>------ Build started: Project: Temp, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>g:\w00t\my received files\engine\engine.h(37) : error C2065: 'CommonDelete' : undeclared identifier
1> g:\w00t\my received files\engine\engine.h(38) : see reference to class template instantiation 'DeleteDestructor<T>' being compiled
1>g:\w00t\my received files\engine\engine.h(37) : fatal error C1001: An internal error has occurred in the compiler.
1>(compiler file 'msc1.cpp', line 1411)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
1>Please choose the Technical Support command on the Visual C++
1> Help menu, or open the Technical Support help file for more information
1>Build log was saved at "file://g:\w00t\Visual Studio 2008\Projects\Temp\Debug\BuildLog.htm"
1>Temp - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I just thought I'd share it with you. I've managed to crash the compiler with an internal error. It's not the first time, either.
It's fun to see how I've managed to cause an internal error in the compiler again :)
(This shouldn't be in GD, should it?)
-
Well, you've done two things.
- You've made me doubt Microsoft's compiler is any good.
- You've made me doubt your ability to code is any good.
Congratulations. ;)
And yes, I'm joking. :)
-
6 was soooo easy to crash. Crashing 9 is definitely harder.
-
I made a mistake in having the function CommonDelete after the struct declaration DeleteDestructor and so it crashed :O
Code:
template<typename T> struct DeleteDestructor
{
typedef CDestructor< T, CommonDelete<T> > type;
};
template<typename T> inline void CommonDelete(T& p) { delete p; }
Didn't work. What's worse is that it crashed :p
But it works as it should if we move them right.
Code:
template<typename T> inline void CommonDelete(T& p) { delete p; }
template<typename T> struct DeleteDestructor
{
typedef CDestructor< T, CommonDelete<T> > type;
};
Anyone crashed their compilers today? :)
-
I do remember crashing MSVC 6 at least once (when I still used it). It was something to do with namespaces. But I can't remember exactly what.
You can crash GCC if you use enough *'s when declaring a pointer, version 2.95 at least. I guess it implements it recursively, because with say 3000 asterisks, GCC performs a stack overflow.
[edit] The number of asterisks you need to crash it depends on how much code comes before the definition, i.e. how much of the stack is already used. [/edit]
-
Do I even want to know why you wanted to make a monster of a pointer? lol...
-
It was an experiment. I was looking at the source code for chicken, which does in fact use like 25 *'s for certain functions, and I wanted to find out if there was a limit. I thought it would be 256 or something, but found that Dev-C++ allowed me to create over 3000.
(I've since discovered that C89 allows 8 levels of indirection, I think.)
-
It would seem MSVC upper limit is 1010. One more and I got a compile error.
Yummy, 1010 stars.
-
With GCC 4.3.1 here, I can compile 10,000 stars.
More stars take significantly longer to compile, though. Compiling 10,000 took several seconds.
I'm sure GCC could do more, I just didn't feel like waiting.
[edit] I'm trying 100,000 now. It's been going for a good 7 minutes, but it hasn't crashed yet. [/edit]
-
:O
I guess that shows how resource hungry Microsoft's compiler is!
GCC is remarkable, I say.
-
Mm'kay, I paused the 100,000 and did 20,000 in just a few minutes. Anyway, it's not really relevant . . . I don't think anyone in their right mind would be using that many.
[edit] The 100,000 just finished, after approximately 15 minutes. This is using one core of a 1.67GHz Core 2 Duo.
Remarkable, indeed. [/edit]
-
Now after trying 100,000 *'s, you can also test to see how many template levels you can use. ;)
Code:
vector<vector<vector<vector<vector<vector<vector<vector<vector<vector<...> > > > > > > > > >
My bets are still on gcc for that one. :D
-
100 is easy.
Code:
$ cat vectors.pl
#!/usr/bin/perl
print <<EOF;
#include <vector>
using std::vector;
int main() {
EOF
$n = int $ARGV[0];
print " ", 'vector<' x $n, 'int', '> ' x $n, "p;\n";
print <<EOF;
return 0;
}
EOF
$ time (./vectors.pl 100 > vectors.cpp && g++ vectors.cpp -o vectors)
real 0m3.585s
user 0m2.956s
sys 0m0.300s
$
I'm still waiting on higher numbers.
[edit] I gave up, but g++ was showing no sign of crashing. I'm sure it would have finished even 1000 eventually. [/edit]
-
I'm surprised at how weak Microsoft's compiler is.
I was only able to achieve 442 recursive template instantiations. Any more and it would crash with an internal error:
Code:
template<int N> struct TemplateTest
{
static const int value = typename TemplateTest<N - 1>::value;
};
template<> struct TemplateTest<0>
{
static const int value = 0;
};
int main()
{
cout << TemplateTest<442>::value; // Works
cout << TemplateTest<443>::value; // Crashes
}
-
GCC has an arbitrary limit, it seems.
Code:
rectemp.cpp:7: error: template instantiation depth exceeds maximum of 500 (use -ftemplate-depth-NN to increase the maximum) instantiating 'struct TemplateTest<500>'
Still, it compiles 500 in a very short period of time.
(I had to remove the "typename" from your example to get it to compile. And add header files, of course.)
[edit] By passing the argument suggested, 1000 compiles in less than two seconds. [/edit]