你有没有崩溃编译器?

Mot*_*tti 19 language-agnostic compiler-construction crash

每个人(至少是使用编译语言的每个人)都遇到了编译错误,但是实际崩溃编译器的次数是多少?

我已经公平地分享了"内部编译器错误",但大多数只是通过重新编译而消失了.你有一个(最小的)代码崩溃了编译器吗?

Jac*_*all 60

我编写了我们使用的编译器,所以它有时会崩溃.


ejg*_*ttl 23

简单.

// -*- C++ -*-

template <int n>
class Foo : public Foo<n+1>
{

};

int main(int, char*[])
{
    Foo<0> x;
    return 0;
};


ejgottl@luna:~/tmp$ g++ -ftemplate-depth-1000000 -Wall foo.cpp -o foo
g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See `<URL:http://gcc.gnu.org/bugs.html>` for instructions.
For Debian GNU/Linux specific bug reporting instructions, see
`<URL:file:///usr/share/doc/gcc-4.2/README.Bugs>`.
Run Code Online (Sandbox Code Playgroud)

  • 嘿,使用C++很便宜;-) ;-) (3认同)

eph*_*ent 16

我还没有让GHC(一个Haskell编译器)崩溃,但是我已经把它弄错了

My brain just exploded.
I can't handle pattern bindings for existentially-quantified constructors.
Run Code Online (Sandbox Code Playgroud)

它很容易解决,除非你有一些棘手的(通常是错误的)设计,否则你不会这样做,但它可能会成为有史以来最好的编译器错误消息.


Jam*_*ran 9

VC现在优雅地捕获它,但在90年代中期,这将崩溃Microsoft C++和Borland C++编译器:

struct MyClass
{
    MyClass operator->() { return *this; }
};


int main(int argc, char* argv[])
{
    MyClass A;
    A->x;
}
Run Code Online (Sandbox Code Playgroud)

重载的operator->本质上是递归的.该函数应返回一个指针,再次应用oper->.这个片段使代码生成无限递归.