]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/gcc/have-you-found-a-bug.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / gcc / have-you-found-a-bug.rst
CommitLineData
c63539ff
ML
1..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6.. index:: bug criteria
7
8.. _bug-criteria:
9
10Have You Found a Bug?
11*********************
12
13If you are not sure whether you have found a bug, here are some guidelines:
14
15.. index:: fatal signal, core dump
16
17* If the compiler gets a fatal signal, for any input whatever, that is a
18 compiler bug. Reliable compilers never crash.
19
20 .. index:: invalid assembly code, assembly code, invalid
21
22* If the compiler produces invalid assembly code, for any input whatever
23 (except an ``asm`` statement), that is a compiler bug, unless the
24 compiler reports errors (not just warnings) which would ordinarily
25 prevent the assembler from being run.
26
27 .. index:: undefined behavior, undefined function value, increment operators
28
29* If the compiler produces valid assembly code that does not correctly
30 execute the input source code, that is a compiler bug.
31
32 However, you must double-check to make sure, because you may have a
33 program whose behavior is undefined, which happened by chance to give
34 the desired results with another C or C++ compiler.
35
36 For example, in many nonoptimizing compilers, you can write :samp:`x;`
37 at the end of a function instead of :samp:`return x;`, with the same
38 results. But the value of the function is undefined if ``return``
39 is omitted; it is not a bug when GCC produces different results.
40
41 Problems often result from expressions with two increment operators,
42 as in ``f (*p++, *p++)``. Your previous compiler might have
43 interpreted that expression the way you intended; GCC might
44 interpret it another way. Neither compiler is wrong. The bug is
45 in your code.
46
47 After you have localized the error to a single source line, it should
48 be easy to check for these things. If your program is correct and
49 well defined, you have found a compiler bug.
50
51* If the compiler produces an error message for valid input, that is a
52 compiler bug.
53
54 .. index:: invalid input
55
56* If the compiler does not produce an error message for invalid input,
57 that is a compiler bug. However, you should note that your idea of
58 'invalid input' might be someone else's idea of 'an extension' or
59 'support for traditional practice'.
60
61* If you are an experienced user of one of the languages GCC supports, your
3ed1b4ce 62 suggestions for improvement of GCC are welcome in any case.