The Art of Bug Reporting

I've noticed that some people in the D bug-reporting community haven't quite got the hang of writing good bug reports.  I have therefore prepared this set of tips for filing bugs efficiently on the D Bugzilla.

1. Summary Line

The first thing people will see of a bug report on Bugzilla is the summary line.  It's important to get this right.  The summary line should describe the bug in a few words, while at the same being specific to the bug.

Here are just a few too-vague summary lines I have seen in my time:

wrong error message
What is this wrong error message?  In what circumstances does it happen?
Compiler crashes on invalid code
What kind of invalid code?
Improve error message.
Improve what error message?  How should it be improved?
static assert doesn't fail as expected
This is most likely due to an expression evaluating to the wrong value.  Describe the bug in terms of that expression not being evaluated correctly.  If a given expression normally evaluates correctly, but doesn't seem to when placed in a static assert, then state that in your bug report.
dmd reject valid code
Describe the nature of the valid code.  And describe the nature of the error message, if you can do so in a few words.
Assertion in dmd
Again, describe the circumstance in which it happens.
should this be a bug??
Since you're putting it into Bugzilla, naturally we understand that you think it's a bug.  (True, people do file feature requests there too, but that's another matter.)  Tell us about this behaviour that you think is a bug.

2. Testcase

Post a short, self-contained code sample.  You could write a testcase from scratch.  Or you could start with the program in which you witnessed the bug and simplify it little by little, testing at each step, until you can't cut it down any more without the bug disappearing.

While trimming, be prepared to undo any trimming that causes the bug to disappear.  A good way of doing this is to comment out a piece of code, test, and then delete the commented-out code if the bug still shows without it.

Short, Self Contained, Correct Example is a good methodology for creating testcases.  Although this piece was intended for teaching you how to reduce a program in order to help find bugs in it, many of the tips work just as well for reducing a program to show a compiler bug.  This may help you with step 1, since reducing the problem may help you to figure out the true essence of the bug and in what circumstances it bites.

Here are a few more specific tips for simplifying a program to show a bug:

If done well, your testcase will:

Once you have your perfect testcase, copy and paste it into your bug report.  If you try copying it manually, you're likely to make typos that invalidate the testcase.  Copy the whole of it, so that the user can test it straight off.  Use the Select All command (Ctrl+A in many Windows-based editors) to make sure you don't accidentally drop a bit.

3. Actual Result

State what happens when you try your testcase.  Copy and paste compiler output (if the problem is compile-time errors) or program output (if it's unexpected behaviour at runtime) into your bug report.  Describe as clearly as you can any unfortunate behaviour beyond the wrong output being generated.

"If you want to find out what happens, you can try it out yourself," I hear you say.  This argument often doesn't hold water:

4. Expected Result

State what you were expecting to happen, if it isn't obvious.

5. Keywords

Remember to assign keywords as appropriate.  The "Keywords" link on bug pages and the bug-reporting page will also take you to the list of keywords.

Usually, any report of a compiler bug should have at least one of these keywords: accepts-invalid, diagnostic, ice, link-failure, performance, rejects-valid, wrong-code, spec.  (The last of these indicates a problem in the D language specification, but applies to compiler bugs (possibly together with another keyword) if the spec is unclear in how the problem code should be treated.)

Assigning keywords might also help you with step 1, since one warning sign of a useless summary line is the existence of a keyword that says what your summary line says.


D Programming Resources | Programming Resources Home