8

An ICE (or internal compiler error) is a "crash" or error that occurs when there's an bug within the compiler itself. Generally the advice is that there isn't anything you can do except report it to the vendor. Classic example:

An internal compiler error is a bug in the compiler. There's not much you can do short of raising the problem with the compiler vendor.

Usually, ICEs happen when you attempt to compile incorrect code, but it is also entirely conceivable for a compiler to choke on valid C++. The language is so complex that it is hard to test every possible feature in all possible combinations.

If you manage to figure out the line of code that's causing the crash, you could try and rewrite it in simpler terms (e.g. by introducing additional local variables or typedefs).

Although this is about , Microsoft's C# compiler has a similar error message. An ICE generally looks like:

somefile.c:1001: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.gentoo.org/> for instructions.

Where the site between the angle brackets is the generic bug tracker for one's system, although I feel it's more appropriate for example to link to the compiler's bug reporting procedure website instead.

Occasionally you may be able to find a workaround, although it's unlikely and better suited by the developers. This is separate from conformance bugs, in which the compiler does not crash, but produces erroneous behavior in accordance to the spec. For example this meta question What do you do with questions that point at a toolchain bug or other such “unlikely” issue? deals with that, despite the misleading title.

Recent example, Internal compiler error GCC-4.8.3

I feel that these questions are inherently duplicates of each other (similar to floating point questions about round-off errors.) However, the questions demonstrate that workarounds are possible (although I don't see this very much in questions.) Closing them would prevent valuable answers.

So are these kinds of questions on-topic? If not, what close reason should be used?

6
  • 10
    Of course they are. Programmers getting stuck because their tool crashes is the most on-topic problem you could think of on a programmer's Q+A site. A repro snippet is expected and required. Commented Nov 28, 2014 at 10:04
  • 2
    But they do need to actually be posed as a question. SO is not for bug reports, those need to go to the vendor.
    – nobody
    Commented Nov 28, 2014 at 21:31
  • @Andrew I can't see how it could be a real question though. An ICE needs to be reported to the vendor, period.
    – user3920237
    Commented Nov 28, 2014 at 21:37
  • Yes, it should certainly be reported to the vendor. But you might not have the luxury of waiting for a fix for a few months (or infinitely) until you can continue working on your code. Asking for workarounds seems useful to me. Commented Nov 28, 2014 at 23:30
  • @Reto For a conformance bug, it's quite easy because you can firmly say "this compiler doesn't support the feature, here's a workaround", but a bug in the compiler is a lot trickier, ergo why workarounds are more rare.
    – user3920237
    Commented Nov 28, 2014 at 23:39
  • Workarounds for ICE's are rare because ICE's are rare, but there invariably is some workaround ... it just can be hard to find.
    – Jim Balter
    Commented Oct 20, 2018 at 19:10

1 Answer 1

5

The dreaded Internal Compiler Error comes in a few different flavors which need to be handled differently when we see them:

  1. ICE-on-valid-code (the OP provides evidence such as Standard cites or multiple diverse compilers accepting the code) -- we may be able to find a workaround, or an alternate solution to their underlying issue. Answering with "this is caused by bug blablabla, fixed in version X.Y" is also valuable for the next person who finds this -- don't forget to link the bug report, or better yet provide a summary of it in addition to the link!
  2. ICE-on-invalid-code (again, the OP provides evidence that their code is invalid) -- we can help by finding them an alternate solution to their underlying problem (it's in some ways an XY question, but politely asking the user to step back and revisit the bigger picture at this point is likely to be well received, because their Y is a dead end).
  3. ICE-on-code-of-unknown-validity ("I have some code below, it's causing an internal compiler error, plz help") -- we first need to figure out if the code's valid or not. Feeding it to multiple compilers (in the case of C++, one would likely use at least two of CLang, GCC, a recent MSVC, and/or some EDG frontended compiler such as ICC as those represent a good cross-section of modern industrial C++ frontends) is helpful for languages where multiple frontends exist; also, language-lawyer eyeballs come in handy when answering these questions (a pertinent Standard cite can settle many matters). Once we have that knowledge in hand, we can pick from the paths above.
  4. ICE-for-some-other-reason-than-their-code -- these probably are off-topic for SO, we can't do much to help people with a compiler that is crashing due to flaky hardware, corruption of some sort, etc...
  5. Other "weird" toolchain errors from other toolchain components (such as inexplicable linker or assembler errors) -- we'll have to handle these on a case-by-case basis. An example of how I took care of one particularly bizarre error can be found here.

Note, also, that some internal compiler errors and other types of "weird" toolchain errors (such as the "dangerous relocation: l32r: literal placed after use" error linked above) are dependent on sizes or offsets, which makes finding MWEs for them harder than the norm. If the OP can come up with one for their error, great! If they cannot, it does not automatically mean the question is low-quality; it simply may mean that minimization is unusually difficult or impossible for the error at hand.

You must log in to answer this question.