Internal Compiler Error

This is a discussion on Internal Compiler Error within the C++ Programming forums, part of the General Programming Boards category; I did it again - what most people have problems with or simply cannot replicate. I made Microsoft's compiler crash! ...

  1. #1
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,021

    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?)
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Well, you've done two things.

    1. You've made me doubt Microsoft's compiler is any good.
    2. You've made me doubt your ability to code is any good.


    Congratulations.

    And yes, I'm joking.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    6 was soooo easy to crash. Crashing 9 is definitely harder.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,021
    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
    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?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    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]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Do I even want to know why you wanted to make a monster of a pointer? lol...

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    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.)
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,021
    It would seem MSVC upper limit is 1010. One more and I got a compile error.
    Yummy, 1010 stars.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    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]
    Last edited by dwks; 07-04-2008 at 05:17 PM.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,021
    :O
    I guess that shows how resource hungry Microsoft's compiler is!
    GCC is remarkable, I say.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    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]
    Last edited by dwks; 07-04-2008 at 05:35 PM.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  12. #12
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    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.

  13. #13
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    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]
    Last edited by dwks; 07-04-2008 at 05:56 PM.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  14. #14
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,021
    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
    }
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  15. #15
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    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]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 02:29 PM
  2. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 07:17 PM
  3. using c++ in c code
    By hannibar in forum C Programming
    Replies: 17
    Last Post: 10-28-2005, 10:09 PM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-30-2005, 12:21 AM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 11:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21